diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-12-15 13:44:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-12-19 06:05:47 +0000 |
commit | f9a97a5d5aca8473845bca2e17c5826b772b8f3c (patch) | |
tree | 580cb178cdcd8b3189afa8ebdf88346490467bcf /idl/inc | |
parent | ScrollableWrapper -> ScrollableDialog (diff) | |
download | core-f9a97a5d5aca8473845bca2e17c5826b772b8f3c.tar.gz core-f9a97a5d5aca8473845bca2e17c5826b772b8f3c.zip |
drop custom hashtable implementation in idl
Change-Id: I2cdb79022e77cdcc03962d392d0d87626a090ac5
Reviewed-on: https://gerrit.libreoffice.org/32043
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'idl/inc')
-rw-r--r-- | idl/inc/database.hxx | 2 | ||||
-rw-r--r-- | idl/inc/globals.hxx | 84 | ||||
-rw-r--r-- | idl/inc/hash.hxx | 50 |
3 files changed, 53 insertions, 83 deletions
diff --git a/idl/inc/database.hxx b/idl/inc/database.hxx index 0ed28a65c0bb..25381c324e34 100644 --- a/idl/inc/database.hxx +++ b/idl/inc/database.hxx @@ -122,7 +122,7 @@ public: void Push( SvMetaObject * pObj ); sal_uInt32 GetUniqueId() { return ++nUniqueId; } bool FindId( const OString& rIdName, sal_uLong * pVal ); - bool InsertId( const OString& rIdName, sal_uLong nVal ); + void InsertId( const OString& rIdName, sal_uLong nVal ); bool ReadIdFile( const OString& rFileName ); SvMetaType * FindType( const OString& rName ); diff --git a/idl/inc/globals.hxx b/idl/inc/globals.hxx index ad8aee0c2e45..ccd413cb55a7 100644 --- a/idl/inc/globals.hxx +++ b/idl/inc/globals.hxx @@ -22,51 +22,49 @@ #include <hash.hxx> -typedef tools::SvRef<SvStringHashEntry> SvStringHashEntryRef; - class SvClassManager; struct SvGlobalHashNames { - SvStringHashEntryRef MM_module; - SvStringHashEntryRef MM_interface; - SvStringHashEntryRef MM_shell; - SvStringHashEntryRef MM_Toggle; - SvStringHashEntryRef MM_AutoUpdate; - SvStringHashEntryRef MM_Asynchron; - SvStringHashEntryRef MM_RecordPerSet; - SvStringHashEntryRef MM_RecordPerItem; - SvStringHashEntryRef MM_NoRecord; - SvStringHashEntryRef MM_RecordAbsolute; - SvStringHashEntryRef MM_enum; - SvStringHashEntryRef MM_UINT16; - SvStringHashEntryRef MM_INT16; - SvStringHashEntryRef MM_UINT32; - SvStringHashEntryRef MM_INT32; - SvStringHashEntryRef MM_BOOL; - SvStringHashEntryRef MM_BYTE; - SvStringHashEntryRef MM_float; - SvStringHashEntryRef MM_double; - SvStringHashEntryRef MM_item; - SvStringHashEntryRef MM_PseudoSlots; - SvStringHashEntryRef MM_import; - SvStringHashEntryRef MM_SlotIdFile; - SvStringHashEntryRef MM_include; - SvStringHashEntryRef MM_ExecMethod; - SvStringHashEntryRef MM_StateMethod; - SvStringHashEntryRef MM_GroupId; - SvStringHashEntryRef MM_Export; - SvStringHashEntryRef MM_PseudoPrefix; - SvStringHashEntryRef MM_define; - SvStringHashEntryRef MM_MenuConfig; - SvStringHashEntryRef MM_ToolBoxConfig; - SvStringHashEntryRef MM_AccelConfig; - SvStringHashEntryRef MM_FastCall; - SvStringHashEntryRef MM_SbxObject; - SvStringHashEntryRef MM_Container; - SvStringHashEntryRef MM_ReadOnlyDoc; - SvStringHashEntryRef MM_struct; - SvStringHashEntryRef MM_SlotType; - SvStringHashEntryRef MM_DisableFlags; + SvStringHashEntry* MM_module; + SvStringHashEntry* MM_interface; + SvStringHashEntry* MM_shell; + SvStringHashEntry* MM_Toggle; + SvStringHashEntry* MM_AutoUpdate; + SvStringHashEntry* MM_Asynchron; + SvStringHashEntry* MM_RecordPerSet; + SvStringHashEntry* MM_RecordPerItem; + SvStringHashEntry* MM_NoRecord; + SvStringHashEntry* MM_RecordAbsolute; + SvStringHashEntry* MM_enum; + SvStringHashEntry* MM_UINT16; + SvStringHashEntry* MM_INT16; + SvStringHashEntry* MM_UINT32; + SvStringHashEntry* MM_INT32; + SvStringHashEntry* MM_BOOL; + SvStringHashEntry* MM_BYTE; + SvStringHashEntry* MM_float; + SvStringHashEntry* MM_double; + SvStringHashEntry* MM_item; + SvStringHashEntry* MM_PseudoSlots; + SvStringHashEntry* MM_import; + SvStringHashEntry* MM_SlotIdFile; + SvStringHashEntry* MM_include; + SvStringHashEntry* MM_ExecMethod; + SvStringHashEntry* MM_StateMethod; + SvStringHashEntry* MM_GroupId; + SvStringHashEntry* MM_Export; + SvStringHashEntry* MM_PseudoPrefix; + SvStringHashEntry* MM_define; + SvStringHashEntry* MM_MenuConfig; + SvStringHashEntry* MM_ToolBoxConfig; + SvStringHashEntry* MM_AccelConfig; + SvStringHashEntry* MM_FastCall; + SvStringHashEntry* MM_SbxObject; + SvStringHashEntry* MM_Container; + SvStringHashEntry* MM_ReadOnlyDoc; + SvStringHashEntry* MM_struct; + SvStringHashEntry* MM_SlotType; + SvStringHashEntry* MM_DisableFlags; SvGlobalHashNames(); }; @@ -88,7 +86,7 @@ inline SvStringHashEntry * SvHash_##Name() \ { \ if( !GetIdlApp().pGlobalNames ) \ GetIdlApp().pGlobalNames = new SvGlobalHashNames(); \ - return GetIdlApp().pGlobalNames->MM_##Name.get(); \ + return GetIdlApp().pGlobalNames->MM_##Name; \ } HASH_INLINE(module) diff --git a/idl/inc/hash.hxx b/idl/inc/hash.hxx index a510fbd35a80..11edb80505de 100644 --- a/idl/inc/hash.hxx +++ b/idl/inc/hash.hxx @@ -23,34 +23,11 @@ #include <rtl/ustring.hxx> #include <tools/ref.hxx> #include <tools/solar.h> -#include <vector> +#include <unordered_map> +#include <memory> -class SvHashTable +class SvStringHashEntry { - sal_uInt32 nMax; // size of hash-tabel - sal_uInt32 nFill; // elements in hash-tabel - sal_uInt32 lAsk; // number of requests - sal_uInt32 lTry; // number of tries -protected: - bool Test_Insert( const OString&, bool bInsert, sal_uInt32 * pInsertPos ); - - // compare element with entry - virtual bool equals( const OString& , sal_uInt32 ) const = 0; - // get hash value from subclass - virtual sal_uInt32 HashFunc( const OString& ) const = 0; -public: - SvHashTable( sal_uInt32 nMaxEntries ); - virtual ~SvHashTable(); - - sal_uInt32 GetMax() const { return nMax; } - - virtual bool IsEntry( sal_uInt32 ) const = 0; -}; - -class SvStringHashTable; -class SvStringHashEntry : public SvRefBase -{ -friend class SvStringHashTable; OString aName; sal_uLong nValue; bool bHasId; @@ -75,22 +52,17 @@ public: sal_uLong GetValue() const { return nValue; } }; -class SvStringHashTable : public SvHashTable +class SvStringHashTable { - SvStringHashEntry* pEntries; -protected: - virtual sal_uInt32 HashFunc( const OString& rElement ) const override; - virtual bool equals( const OString &rElement, sal_uInt32 nIndex ) const override; -public: - SvStringHashTable( sal_uInt32 nMaxEntries ); // max size of hash-tabel - virtual ~SvStringHashTable() override; + std::unordered_map<sal_uInt32, std::unique_ptr<SvStringHashEntry>> maInt2EntryMap; + std::unordered_map<OString, sal_uInt32, OStringHash> maString2IntMap; + sal_uInt32 mnNextId = 0; +public: + SvStringHashEntry * Insert( OString const & rElement, sal_uInt32 * pInsertPos ); + bool Test( OString const & rElement, sal_uInt32 * pInsertPos ); + SvStringHashEntry * Get( sal_uInt32 nInsertPos ) const; OString GetNearString( const OString& rName ) const; - virtual bool IsEntry( sal_uInt32 nIndex ) const override; - - bool Insert( const OString& rStr, sal_uInt32 * pHash ); // insert string - bool Test( const OString& rStr, sal_uInt32 * pHash ) const; // test of insert string - SvStringHashEntry * Get ( sal_uInt32 nIndex ) const; // return pointer to string }; #endif // INCLUDED_IDL_INC_HASH_HXX |