From a2f068b2ad7005038e2193bdcc42622fedf9c188 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 16 Mar 2016 15:33:44 +1100 Subject: [PATCH] Bug 1253085 - Remove the |PLDHashTable*| argument from PLDHash{HashKey,MatchEntry}. r=froydnj. This is easy because it's never needed. --HG-- extra : rebase_source : 78830dab41c40a1544fa55fc69ca9c1c6709d767 --- dom/base/nsContentList.cpp | 13 +++----- dom/base/nsScriptNameSpaceManager.cpp | 5 ++- .../commandhandler/nsCommandParams.cpp | 5 ++- .../commandhandler/nsCommandParams.h | 5 ++- gfx/thebes/gfxFT2FontList.cpp | 5 ++- js/xpconnect/src/XPCMaps.cpp | 20 +++++------- js/xpconnect/src/XPCMaps.h | 14 +++------ layout/base/nsFrameManager.cpp | 3 +- layout/style/nsCSSRuleProcessor.cpp | 31 +++++++------------ layout/style/nsHTMLStyleSheet.cpp | 10 +++--- layout/style/nsRuleNode.cpp | 7 ++--- layout/style/nsRuleNode.h | 6 ++-- layout/tables/SpanningCellSorter.cpp | 5 ++- layout/tables/SpanningCellSorter.h | 6 ++-- modules/libpref/prefapi.cpp | 3 +- netwerk/base/nsLoadGroup.cpp | 3 +- netwerk/cache/nsCacheEntry.cpp | 5 ++- netwerk/cache/nsCacheEntry.h | 7 ++--- netwerk/cache/nsDiskCacheBinding.cpp | 7 ++--- netwerk/dns/nsHostResolver.cpp | 5 ++- netwerk/protocol/http/nsHttp.cpp | 5 ++- parser/htmlparser/nsHTMLEntities.cpp | 13 +++----- rdf/base/nsRDFService.cpp | 25 ++++++--------- security/manager/ssl/nsCertOverrideService.h | 4 +-- security/manager/ssl/nsCertTree.cpp | 3 +- security/manager/ssl/nsClientAuthRemember.h | 4 +-- security/manager/ssl/nsNSSShutDown.cpp | 3 +- .../manager/ssl/nsSecureBrowserUIImpl.cpp | 3 +- xpcom/base/nsCycleCollector.cpp | 4 +-- xpcom/base/nsMemoryReporterManager.cpp | 5 ++- xpcom/ds/nsAtomTable.cpp | 5 ++- xpcom/ds/nsStaticNameTable.cpp | 5 ++- xpcom/glue/PLDHashTable.cpp | 18 +++++------ xpcom/glue/PLDHashTable.h | 25 ++++++--------- xpcom/glue/nsTHashtable.h | 11 +++---- xpcom/tests/gtest/TestPLDHash.cpp | 2 +- 36 files changed, 111 insertions(+), 189 deletions(-) diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index e09239b376cd..82e5b1aa9dd4 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -171,16 +171,14 @@ struct ContentListHashEntry : public PLDHashEntryHdr }; static PLDHashNumber -ContentListHashtableHashKey(PLDHashTable *table, const void *key) +ContentListHashtableHashKey(const void *key) { const nsContentListKey* list = static_cast(key); return list->GetHash(); } static bool -ContentListHashtableMatchEntry(PLDHashTable *table, - const PLDHashEntryHdr *entry, - const void *key) +ContentListHashtableMatchEntry(const PLDHashEntryHdr *entry, const void *key) { const ContentListHashEntry *e = static_cast(entry); @@ -278,7 +276,7 @@ struct FuncStringContentListHashEntry : public PLDHashEntryHdr }; static PLDHashNumber -FuncStringContentListHashtableHashKey(PLDHashTable *table, const void *key) +FuncStringContentListHashtableHashKey(const void *key) { const nsFuncStringCacheKey* funcStringKey = static_cast(key); @@ -286,9 +284,8 @@ FuncStringContentListHashtableHashKey(PLDHashTable *table, const void *key) } static bool -FuncStringContentListHashtableMatchEntry(PLDHashTable *table, - const PLDHashEntryHdr *entry, - const void *key) +FuncStringContentListHashtableMatchEntry(const PLDHashEntryHdr *entry, + const void *key) { const FuncStringContentListHashEntry *e = static_cast(entry); diff --git a/dom/base/nsScriptNameSpaceManager.cpp b/dom/base/nsScriptNameSpaceManager.cpp index d4e78c4935fe..09b102cbd533 100644 --- a/dom/base/nsScriptNameSpaceManager.cpp +++ b/dom/base/nsScriptNameSpaceManager.cpp @@ -36,15 +36,14 @@ using namespace mozilla; static PLDHashNumber -GlobalNameHashHashKey(PLDHashTable *table, const void *key) +GlobalNameHashHashKey(const void *key) { const nsAString *str = static_cast(key); return HashString(*str); } static bool -GlobalNameHashMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *entry, - const void *key) +GlobalNameHashMatchEntry(const PLDHashEntryHdr *entry, const void *key) { const GlobalNameMapEntry *e = static_cast(entry); diff --git a/embedding/components/commandhandler/nsCommandParams.cpp b/embedding/components/commandhandler/nsCommandParams.cpp index 87d68275c11f..86647d4ddb63 100644 --- a/embedding/components/commandhandler/nsCommandParams.cpp +++ b/embedding/components/commandhandler/nsCommandParams.cpp @@ -230,14 +230,13 @@ nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t aEntryType) } PLDHashNumber -nsCommandParams::HashKey(PLDHashTable* aTable, const void* aKey) +nsCommandParams::HashKey(const void* aKey) { return HashString((const char*)aKey); } bool -nsCommandParams::HashMatchEntry(PLDHashTable* aTable, - const PLDHashEntryHdr* aEntry, const void* aKey) +nsCommandParams::HashMatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey) { const char* keyString = (const char*)aKey; const HashEntry* thisEntry = static_cast(aEntry); diff --git a/embedding/components/commandhandler/nsCommandParams.h b/embedding/components/commandhandler/nsCommandParams.h index 5f90caf99fd6..52df28d791ac 100644 --- a/embedding/components/commandhandler/nsCommandParams.h +++ b/embedding/components/commandhandler/nsCommandParams.h @@ -114,10 +114,9 @@ protected: HashEntry* GetOrMakeEntry(const char* aName, uint8_t aEntryType); protected: - static PLDHashNumber HashKey(PLDHashTable* aTable, const void* aKey); + static PLDHashNumber HashKey(const void* aKey); - static bool HashMatchEntry(PLDHashTable* aTable, - const PLDHashEntryHdr* aEntry, const void* aKey); + static bool HashMatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey); static void HashMoveEntry(PLDHashTable* aTable, const PLDHashEntryHdr* aFrom, PLDHashEntryHdr* aTo); diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 37fa074b0308..8658a50a5d7b 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -759,13 +759,12 @@ private: bool mFileExists; } FNCMapEntry; - static PLDHashNumber StringHash(PLDHashTable *table, const void *key) + static PLDHashNumber StringHash(const void *key) { return HashString(reinterpret_cast(key)); } - static bool HashMatchEntry(PLDHashTable *table, - const PLDHashEntryHdr *aHdr, const void *key) + static bool HashMatchEntry(const PLDHashEntryHdr *aHdr, const void *key) { const FNCMapEntry* entry = static_cast(aHdr); diff --git a/js/xpconnect/src/XPCMaps.cpp b/js/xpconnect/src/XPCMaps.cpp index 45876a9138d7..97d25833dff1 100644 --- a/js/xpconnect/src/XPCMaps.cpp +++ b/js/xpconnect/src/XPCMaps.cpp @@ -21,22 +21,20 @@ using namespace mozilla; // the pointer to the nsID. static PLDHashNumber -HashIIDPtrKey(PLDHashTable* table, const void* key) +HashIIDPtrKey(const void* key) { return *((js::HashNumber*)key); } static bool -MatchIIDPtrKey(PLDHashTable* table, - const PLDHashEntryHdr* entry, - const void* key) +MatchIIDPtrKey(const PLDHashEntryHdr* entry, const void* key) { return ((const nsID*)key)-> Equals(*((const nsID*)((PLDHashEntryStub*)entry)->key)); } static PLDHashNumber -HashNativeKey(PLDHashTable* table, const void* key) +HashNativeKey(const void* key) { XPCNativeSetKey* Key = (XPCNativeSetKey*) key; @@ -319,9 +317,7 @@ ClassInfo2WrappedNativeProtoMap::SizeOfIncludingThis(mozilla::MallocSizeOf mallo // implement NativeSetMap... bool -NativeSetMap::Entry::Match(PLDHashTable* table, - const PLDHashEntryHdr* entry, - const void* key) +NativeSetMap::Entry::Match(const PLDHashEntryHdr* entry, const void* key) { XPCNativeSetKey* Key = (XPCNativeSetKey*) key; @@ -431,8 +427,7 @@ NativeSetMap::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const // implement IID2ThisTranslatorMap... bool -IID2ThisTranslatorMap::Entry::Match(PLDHashTable* table, - const PLDHashEntryHdr* entry, +IID2ThisTranslatorMap::Entry::Match(const PLDHashEntryHdr* entry, const void* key) { return ((const nsID*)key)->Equals(((Entry*)entry)->key); @@ -473,7 +468,7 @@ IID2ThisTranslatorMap::~IID2ThisTranslatorMap() /***************************************************************************/ PLDHashNumber -XPCNativeScriptableSharedMap::Entry::Hash(PLDHashTable* table, const void* key) +XPCNativeScriptableSharedMap::Entry::Hash(const void* key) { PLDHashNumber h; const unsigned char* s; @@ -492,8 +487,7 @@ XPCNativeScriptableSharedMap::Entry::Hash(PLDHashTable* table, const void* key) } bool -XPCNativeScriptableSharedMap::Entry::Match(PLDHashTable* table, - const PLDHashEntryHdr* entry, +XPCNativeScriptableSharedMap::Entry::Match(const PLDHashEntryHdr* entry, const void* key) { XPCNativeScriptableShared* obj1 = diff --git a/js/xpconnect/src/XPCMaps.h b/js/xpconnect/src/XPCMaps.h index 7d585e93ea7e..23f8803362ac 100644 --- a/js/xpconnect/src/XPCMaps.h +++ b/js/xpconnect/src/XPCMaps.h @@ -390,9 +390,7 @@ public: XPCNativeSet* key_value; static bool - Match(PLDHashTable* table, - const PLDHashEntryHdr* entry, - const void* key); + Match(const PLDHashEntryHdr* entry, const void* key); static const struct PLDHashTableOps sOps; }; @@ -459,9 +457,7 @@ public: nsCOMPtr value; static bool - Match(PLDHashTable* table, - const PLDHashEntryHdr* entry, - const void* key); + Match(const PLDHashEntryHdr* entry, const void* key); static void Clear(PLDHashTable* table, PLDHashEntryHdr* entry); @@ -513,12 +509,10 @@ public: XPCNativeScriptableShared* key; static PLDHashNumber - Hash(PLDHashTable* table, const void* key); + Hash(const void* key); static bool - Match(PLDHashTable* table, - const PLDHashEntryHdr* entry, - const void* key); + Match(const PLDHashEntryHdr* entry, const void* key); static const struct PLDHashTableOps sOps; }; diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index d4bed307493c..46c76235c873 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -57,8 +57,7 @@ struct PlaceholderMapEntry : public PLDHashEntryHdr { }; static bool -PlaceholderMapMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +PlaceholderMapMatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const PlaceholderMapEntry *entry = static_cast(hdr); diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index f9805b8de50b..9e4ef3fd6ee6 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -185,7 +185,7 @@ struct RuleHashTagTableEntry : public RuleHashTableEntry { }; static PLDHashNumber -RuleHash_CIHashKey(PLDHashTable *table, const void *key) +RuleHash_CIHashKey(const void *key) { nsIAtom *atom = const_cast(static_cast(key)); @@ -232,29 +232,25 @@ CSMatchAtoms(const void* key, nsIAtom *entry_atom) } static bool -RuleHash_ClassCIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +RuleHash_ClassCIMatchEntry(const PLDHashEntryHdr *hdr, const void *key) { return CIMatchAtoms(key, SubjectSelectorForRuleHash(hdr)->mClassList->mAtom); } static bool -RuleHash_IdCIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +RuleHash_IdCIMatchEntry(const PLDHashEntryHdr *hdr, const void *key) { return CIMatchAtoms(key, SubjectSelectorForRuleHash(hdr)->mIDList->mAtom); } static bool -RuleHash_ClassCSMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +RuleHash_ClassCSMatchEntry(const PLDHashEntryHdr *hdr, const void *key) { return CSMatchAtoms(key, SubjectSelectorForRuleHash(hdr)->mClassList->mAtom); } static bool -RuleHash_IdCSMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +RuleHash_IdCSMatchEntry(const PLDHashEntryHdr *hdr, const void *key) { return CSMatchAtoms(key, SubjectSelectorForRuleHash(hdr)->mIDList->mAtom); } @@ -287,8 +283,7 @@ RuleHash_MoveEntry(PLDHashTable *table, const PLDHashEntryHdr *from, } static bool -RuleHash_TagTable_MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +RuleHash_TagTable_MatchEntry(const PLDHashEntryHdr *hdr, const void *key) { nsIAtom *match_atom = const_cast(static_cast(key)); nsIAtom *entry_atom = static_cast(hdr)->mTag; @@ -326,15 +321,13 @@ RuleHash_TagTable_MoveEntry(PLDHashTable *table, const PLDHashEntryHdr *from, } static PLDHashNumber -RuleHash_NameSpaceTable_HashKey(PLDHashTable *table, const void *key) +RuleHash_NameSpaceTable_HashKey(const void *key) { return NS_PTR_TO_INT32(key); } static bool -RuleHash_NameSpaceTable_MatchEntry(PLDHashTable *table, - const PLDHashEntryHdr *hdr, - const void *key) +RuleHash_NameSpaceTable_MatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const RuleHashTableEntry *entry = static_cast(hdr); @@ -818,8 +811,7 @@ AtomSelector_MoveEntry(PLDHashTable *table, const PLDHashEntryHdr *from, } static bool -AtomSelector_CIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +AtomSelector_CIMatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const AtomSelectorEntry *entry = static_cast(hdr); return CIMatchAtoms(key, entry->mAtom); @@ -3490,14 +3482,13 @@ struct RuleByWeightEntry : public PLDHashEntryHdr { }; static PLDHashNumber -HashIntKey(PLDHashTable *table, const void *key) +HashIntKey(const void *key) { return PLDHashNumber(NS_PTR_TO_INT32(key)); } static bool -MatchWeightEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +MatchWeightEntry(const PLDHashEntryHdr *hdr, const void *key) { const RuleByWeightEntry *entry = (const RuleByWeightEntry *)hdr; return entry->data.mWeight == NS_PTR_TO_INT32(key); diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 9347dc8631a3..56128261bef7 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -164,7 +164,7 @@ struct MappedAttrTableEntry : public PLDHashEntryHdr { }; static PLDHashNumber -MappedAttrTable_HashKey(PLDHashTable *table, const void *key) +MappedAttrTable_HashKey(const void *key) { nsMappedAttributes *attributes = static_cast(const_cast(key)); @@ -182,8 +182,7 @@ MappedAttrTable_ClearEntry(PLDHashTable *table, PLDHashEntryHdr *hdr) } static bool -MappedAttrTable_MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +MappedAttrTable_MatchEntry(const PLDHashEntryHdr *hdr, const void *key) { nsMappedAttributes *attributes = static_cast(const_cast(key)); @@ -208,7 +207,7 @@ struct LangRuleTableEntry : public PLDHashEntryHdr { }; static PLDHashNumber -LangRuleTable_HashKey(PLDHashTable *table, const void *key) +LangRuleTable_HashKey(const void *key) { const nsString *lang = static_cast(key); return HashString(*lang); @@ -224,8 +223,7 @@ LangRuleTable_ClearEntry(PLDHashTable *table, PLDHashEntryHdr *hdr) } static bool -LangRuleTable_MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +LangRuleTable_MatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const nsString *lang = static_cast(key); const LangRuleTableEntry *entry = static_cast(hdr); diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 0dc19c99cb94..566058f19d57 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -128,18 +128,17 @@ struct ChildrenHashEntry : public PLDHashEntryHdr { }; /* static */ PLDHashNumber -nsRuleNode::ChildrenHashHashKey(PLDHashTable *aTable, const void *aKey) +nsRuleNode::ChildrenHashHashKey(const void *aKey) { const nsRuleNode::Key *key = static_cast(aKey); // Disagreement on importance and level for the same rule is extremely // rare, so hash just on the rule. - return PLDHashTable::HashVoidPtrKeyStub(aTable, key->mRule); + return PLDHashTable::HashVoidPtrKeyStub(key->mRule); } /* static */ bool -nsRuleNode::ChildrenHashMatchEntry(PLDHashTable *aTable, - const PLDHashEntryHdr *aHdr, +nsRuleNode::ChildrenHashMatchEntry(const PLDHashEntryHdr *aHdr, const void *aKey) { const ChildrenHashEntry *entry = diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index f5298d8da193..3b439d139a29 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -451,12 +451,10 @@ private: }; static PLDHashNumber - ChildrenHashHashKey(PLDHashTable *aTable, const void *aKey); + ChildrenHashHashKey(const void *aKey); static bool - ChildrenHashMatchEntry(PLDHashTable *aTable, - const PLDHashEntryHdr *aHdr, - const void *aKey); + ChildrenHashMatchEntry(const PLDHashEntryHdr *aHdr, const void *aKey); void SweepChildren(nsTArray& aSweepQueue); bool DestroyIfNotMarked(); diff --git a/layout/tables/SpanningCellSorter.cpp b/layout/tables/SpanningCellSorter.cpp index 812a3a58c1a1..c67d784bbad2 100644 --- a/layout/tables/SpanningCellSorter.cpp +++ b/layout/tables/SpanningCellSorter.cpp @@ -37,14 +37,13 @@ SpanningCellSorter::HashTableOps = { }; /* static */ PLDHashNumber -SpanningCellSorter::HashTableHashKey(PLDHashTable *table, const void *key) +SpanningCellSorter::HashTableHashKey(const void *key) { return NS_PTR_TO_INT32(key); } /* static */ bool -SpanningCellSorter::HashTableMatchEntry(PLDHashTable *table, - const PLDHashEntryHdr *hdr, +SpanningCellSorter::HashTableMatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const HashTableEntry *entry = static_cast(hdr); diff --git a/layout/tables/SpanningCellSorter.h b/layout/tables/SpanningCellSorter.h index 8a0ac329061c..30139c0e387f 100644 --- a/layout/tables/SpanningCellSorter.h +++ b/layout/tables/SpanningCellSorter.h @@ -70,11 +70,9 @@ private: static const PLDHashTableOps HashTableOps; - static PLDHashNumber - HashTableHashKey(PLDHashTable *table, const void *key); + static PLDHashNumber HashTableHashKey(const void *key); static bool - HashTableMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key); + HashTableMatchEntry(const PLDHashEntryHdr *hdr, const void *key); static int SortArray(const void *a, const void *b, void *closure); diff --git a/modules/libpref/prefapi.cpp b/modules/libpref/prefapi.cpp index 9d0c92f1e285..30927039adad 100644 --- a/modules/libpref/prefapi.cpp +++ b/modules/libpref/prefapi.cpp @@ -54,8 +54,7 @@ clearPrefEntry(PLDHashTable *table, PLDHashEntryHdr *entry) } static bool -matchPrefEntry(PLDHashTable*, const PLDHashEntryHdr* entry, - const void* key) +matchPrefEntry(const PLDHashEntryHdr* entry, const void* key) { const PrefHashEntry *prefEntry = static_cast(entry); diff --git a/netwerk/base/nsLoadGroup.cpp b/netwerk/base/nsLoadGroup.cpp index a68dad72ae14..ea47df463da1 100644 --- a/netwerk/base/nsLoadGroup.cpp +++ b/netwerk/base/nsLoadGroup.cpp @@ -56,8 +56,7 @@ public: }; static bool -RequestHashMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *entry, - const void *key) +RequestHashMatchEntry(const PLDHashEntryHdr *entry, const void *key) { const RequestMapEntry *e = static_cast(entry); diff --git a/netwerk/cache/nsCacheEntry.cpp b/netwerk/cache/nsCacheEntry.cpp index a2507b10621e..2d8f422830fa 100644 --- a/netwerk/cache/nsCacheEntry.cpp +++ b/netwerk/cache/nsCacheEntry.cpp @@ -476,14 +476,13 @@ nsCacheEntryHashTable::Iter() */ PLDHashNumber -nsCacheEntryHashTable::HashKey( PLDHashTable *table, const void *key) +nsCacheEntryHashTable::HashKey(const void *key) { return HashString(*static_cast(key)); } bool -nsCacheEntryHashTable::MatchEntry(PLDHashTable * /* table */, - const PLDHashEntryHdr * hashEntry, +nsCacheEntryHashTable::MatchEntry(const PLDHashEntryHdr * hashEntry, const void * key) { NS_ASSERTION(key != nullptr, "### nsCacheEntryHashTable::MatchEntry : null key"); diff --git a/netwerk/cache/nsCacheEntry.h b/netwerk/cache/nsCacheEntry.h index 84ae2fa6f5e4..bef7d9ace433 100644 --- a/netwerk/cache/nsCacheEntry.h +++ b/netwerk/cache/nsCacheEntry.h @@ -278,11 +278,10 @@ public: private: // PLDHashTable operation callbacks - static PLDHashNumber HashKey( PLDHashTable *table, const void *key); + static PLDHashNumber HashKey(const void *key); - static bool MatchEntry( PLDHashTable * table, - const PLDHashEntryHdr * entry, - const void * key); + static bool MatchEntry(const PLDHashEntryHdr * entry, + const void * key); static void MoveEntry( PLDHashTable *table, const PLDHashEntryHdr *from, diff --git a/netwerk/cache/nsDiskCacheBinding.cpp b/netwerk/cache/nsDiskCacheBinding.cpp index 264a9fb7bc1a..ca56a0fe8eaa 100644 --- a/netwerk/cache/nsDiskCacheBinding.cpp +++ b/netwerk/cache/nsDiskCacheBinding.cpp @@ -24,16 +24,15 @@ struct HashTableEntry : PLDHashEntryHdr { static PLDHashNumber -HashKey( PLDHashTable *table, const void *key) +HashKey(const void *key) { return (PLDHashNumber) NS_PTR_TO_INT32(key); } static bool -MatchEntry(PLDHashTable * /* table */, - const PLDHashEntryHdr * header, - const void * key) +MatchEntry(const PLDHashEntryHdr * header, + const void * key) { HashTableEntry * hashEntry = (HashTableEntry *) header; return (hashEntry->mBinding->mRecord.HashNumber() == (PLDHashNumber) NS_PTR_TO_INT32(key)); diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index 94164d7a70ed..bc8484f5d353 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -394,7 +394,7 @@ struct nsHostDBEnt : PLDHashEntryHdr }; static PLDHashNumber -HostDB_HashKey(PLDHashTable *table, const void *key) +HostDB_HashKey(const void *key) { const nsHostKey *hk = static_cast(key); return AddToHash(HashString(hk->host), RES_KEY_FLAGS(hk->flags), hk->af, @@ -402,8 +402,7 @@ HostDB_HashKey(PLDHashTable *table, const void *key) } static bool -HostDB_MatchEntry(PLDHashTable *table, - const PLDHashEntryHdr *entry, +HostDB_MatchEntry(const PLDHashEntryHdr *entry, const void *key) { const nsHostDBEnt *he = static_cast(entry); diff --git a/netwerk/protocol/http/nsHttp.cpp b/netwerk/protocol/http/nsHttp.cpp index 0a372e99c73a..4b2724a2fe94 100644 --- a/netwerk/protocol/http/nsHttp.cpp +++ b/netwerk/protocol/http/nsHttp.cpp @@ -61,7 +61,7 @@ NewHeapAtom(const char *value) { // Hash string ignore case, based on PL_HashString static PLDHashNumber -StringHash(PLDHashTable *table, const void *key) +StringHash(const void *key) { PLDHashNumber h = 0; for (const char *s = reinterpret_cast(key); *s; ++s) @@ -70,8 +70,7 @@ StringHash(PLDHashTable *table, const void *key) } static bool -StringCompare(PLDHashTable *table, const PLDHashEntryHdr *entry, - const void *testKey) +StringCompare(const PLDHashEntryHdr *entry, const void *testKey) { const void *entryKey = reinterpret_cast(entry)->key; diff --git a/parser/htmlparser/nsHTMLEntities.cpp b/parser/htmlparser/nsHTMLEntities.cpp index 6a8142a9c24b..ffe749a2d4b9 100644 --- a/parser/htmlparser/nsHTMLEntities.cpp +++ b/parser/htmlparser/nsHTMLEntities.cpp @@ -23,30 +23,25 @@ struct EntityNodeEntry : public PLDHashEntryHdr const EntityNode* node; }; -static bool - matchNodeString(PLDHashTable*, const PLDHashEntryHdr* aHdr, - const void* key) +static bool matchNodeString(const PLDHashEntryHdr* aHdr, const void* key) { const EntityNodeEntry* entry = static_cast(aHdr); const char* str = static_cast(key); return (nsCRT::strcmp(entry->node->mStr, str) == 0); } -static bool - matchNodeUnicode(PLDHashTable*, const PLDHashEntryHdr* aHdr, - const void* key) +static bool matchNodeUnicode(const PLDHashEntryHdr* aHdr, const void* key) { const EntityNodeEntry* entry = static_cast(aHdr); const int32_t ucode = NS_PTR_TO_INT32(key); return (entry->node->mUnicode == ucode); } -static PLDHashNumber - hashUnicodeValue(PLDHashTable*, const void* key) +static PLDHashNumber hashUnicodeValue(const void* key) { // key is actually the unicode value return PLDHashNumber(NS_PTR_TO_INT32(key)); - } +} static const PLDHashTableOps EntityToUnicodeOps = { diff --git a/rdf/base/nsRDFService.cpp b/rdf/base/nsRDFService.cpp index 7774fbdbd2af..368b2d30ac64 100644 --- a/rdf/base/nsRDFService.cpp +++ b/rdf/base/nsRDFService.cpp @@ -121,14 +121,13 @@ struct ResourceHashEntry : public PLDHashEntryHdr { nsIRDFResource *mResource; static PLDHashNumber - HashKey(PLDHashTable *table, const void *key) + HashKey(const void *key) { return HashString(static_cast(key)); } static bool - MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) + MatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const ResourceHashEntry *entry = static_cast(hdr); @@ -156,14 +155,13 @@ struct LiteralHashEntry : public PLDHashEntryHdr { const char16_t *mKey; static PLDHashNumber - HashKey(PLDHashTable *table, const void *key) + HashKey(const void *key) { return HashString(static_cast(key)); } static bool - MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) + MatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const LiteralHashEntry *entry = static_cast(hdr); @@ -191,14 +189,13 @@ struct IntHashEntry : public PLDHashEntryHdr { int32_t mKey; static PLDHashNumber - HashKey(PLDHashTable *table, const void *key) + HashKey(const void *key) { return PLDHashNumber(*static_cast(key)); } static bool - MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) + MatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const IntHashEntry *entry = static_cast(hdr); @@ -225,7 +222,7 @@ struct DateHashEntry : public PLDHashEntryHdr { PRTime mKey; static PLDHashNumber - HashKey(PLDHashTable *table, const void *key) + HashKey(const void *key) { // xor the low 32 bits with the high 32 bits. PRTime t = *static_cast(key); @@ -235,8 +232,7 @@ struct DateHashEntry : public PLDHashEntryHdr { } static bool - MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) + MatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const DateHashEntry *entry = static_cast(hdr); @@ -338,7 +334,7 @@ struct BlobHashEntry : public PLDHashEntryHdr { BlobImpl *mBlob; static PLDHashNumber - HashKey(PLDHashTable *table, const void *key) + HashKey(const void *key) { const BlobImpl::Data *data = static_cast(key); @@ -346,8 +342,7 @@ struct BlobHashEntry : public PLDHashEntryHdr { } static bool - MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) + MatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const BlobHashEntry *entry = static_cast(hdr); diff --git a/security/manager/ssl/nsCertOverrideService.h b/security/manager/ssl/nsCertOverrideService.h index 225b8c2654e9..bb410f8da814 100644 --- a/security/manager/ssl/nsCertOverrideService.h +++ b/security/manager/ssl/nsCertOverrideService.h @@ -107,9 +107,7 @@ class nsCertOverrideEntry final : public PLDHashEntryHdr static PLDHashNumber HashKey(KeyTypePointer aKey) { - // PLDHashTable::HashStringKey doesn't use the table parameter, so we can - // safely pass nullptr - return PLDHashTable::HashStringKey(nullptr, aKey); + return PLDHashTable::HashStringKey(aKey); } enum { ALLOW_MEMMOVE = false }; diff --git a/security/manager/ssl/nsCertTree.cpp b/security/manager/ssl/nsCertTree.cpp index 615d82c4f92d..b63e6fbc7e59 100644 --- a/security/manager/ssl/nsCertTree.cpp +++ b/security/manager/ssl/nsCertTree.cpp @@ -61,8 +61,7 @@ CompareCacheHashEntry::CompareCacheHashEntry() } static bool -CompareCacheMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +CompareCacheMatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const CompareCacheHashEntryPtr *entryPtr = static_cast(hdr); return entryPtr->entry->key == key; diff --git a/security/manager/ssl/nsClientAuthRemember.h b/security/manager/ssl/nsClientAuthRemember.h index a4d00f5ae1c8..a5070a04d4f2 100644 --- a/security/manager/ssl/nsClientAuthRemember.h +++ b/security/manager/ssl/nsClientAuthRemember.h @@ -87,9 +87,7 @@ class nsClientAuthRememberEntry final : public PLDHashEntryHdr static PLDHashNumber HashKey(KeyTypePointer aKey) { - // PLDHashTable::HashStringKey doesn't use the table parameter, so we can - // safely pass nullptr - return PLDHashTable::HashStringKey(nullptr, aKey); + return PLDHashTable::HashStringKey(aKey); } enum { ALLOW_MEMMOVE = false }; diff --git a/security/manager/ssl/nsNSSShutDown.cpp b/security/manager/ssl/nsNSSShutDown.cpp index b2337cdf798e..f6b0db17a7e6 100644 --- a/security/manager/ssl/nsNSSShutDown.cpp +++ b/security/manager/ssl/nsNSSShutDown.cpp @@ -14,8 +14,7 @@ struct ObjectHashEntry : PLDHashEntryHdr { }; static bool -ObjectSetMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +ObjectSetMatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const ObjectHashEntry *entry = static_cast(hdr); return entry->obj == static_cast(key); diff --git a/security/manager/ssl/nsSecureBrowserUIImpl.cpp b/security/manager/ssl/nsSecureBrowserUIImpl.cpp index b1c1e96108ca..9d987393ed2e 100644 --- a/security/manager/ssl/nsSecureBrowserUIImpl.cpp +++ b/security/manager/ssl/nsSecureBrowserUIImpl.cpp @@ -56,8 +56,7 @@ struct RequestHashEntry : PLDHashEntryHdr { }; static bool -RequestMapMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +RequestMapMatchEntry(const PLDHashEntryHdr *hdr, const void *key) { const RequestHashEntry *entry = static_cast(hdr); return entry->r == key; diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index a54f8af15afd..ca95ea5970f4 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -794,9 +794,7 @@ struct PtrToNodeEntry : public PLDHashEntryHdr }; static bool -PtrToNodeMatchEntry(PLDHashTable* aTable, - const PLDHashEntryHdr* aEntry, - const void* aKey) +PtrToNodeMatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey) { const PtrToNodeEntry* n = static_cast(aEntry); return n->mNode->mPointer == aKey; diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 39c402ee402f..43a04d04289b 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -756,15 +756,14 @@ struct SegmentKind struct SegmentEntry : public PLDHashEntryHdr { - static PLDHashNumber HashKey(PLDHashTable* aTable, const void* aKey) + static PLDHashNumber HashKey(const void* aKey) { auto kind = static_cast(aKey); return mozilla::HashGeneric(kind->mState, kind->mType, kind->mProtect, kind->mIsStack); } - static bool MatchEntry(PLDHashTable* aTable, - const PLDHashEntryHdr* aEntry, const void* aKey) + static bool MatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey) { auto kind = static_cast(aKey); auto entry = static_cast(aEntry); diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index 6ca0e8001f57..6e1e5256cac6 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -236,15 +236,14 @@ struct AtomTableKey }; static PLDHashNumber -AtomTableGetHash(PLDHashTable* aTable, const void* aKey) +AtomTableGetHash(const void* aKey) { const AtomTableKey* k = static_cast(aKey); return k->mHash; } static bool -AtomTableMatchKey(PLDHashTable* aTable, const PLDHashEntryHdr* aEntry, - const void* aKey) +AtomTableMatchKey(const PLDHashEntryHdr* aEntry, const void* aKey) { const AtomTableEntry* he = static_cast(aEntry); const AtomTableKey* k = static_cast(aKey); diff --git a/xpcom/ds/nsStaticNameTable.cpp b/xpcom/ds/nsStaticNameTable.cpp index d5fa02356d51..26bd172a77bd 100644 --- a/xpcom/ds/nsStaticNameTable.cpp +++ b/xpcom/ds/nsStaticNameTable.cpp @@ -50,8 +50,7 @@ struct NameTableEntry : public PLDHashEntryHdr }; static bool -matchNameKeysCaseInsensitive(PLDHashTable*, const PLDHashEntryHdr* aHdr, - const void* aVoidKey) +matchNameKeysCaseInsensitive(const PLDHashEntryHdr* aHdr, const void* aVoidKey) { auto entry = static_cast(aHdr); auto key = static_cast(aVoidKey); @@ -71,7 +70,7 @@ matchNameKeysCaseInsensitive(PLDHashTable*, const PLDHashEntryHdr* aHdr, * matter. */ static PLDHashNumber -caseInsensitiveStringHashKey(PLDHashTable* aTable, const void* aKey) +caseInsensitiveStringHashKey(const void* aKey) { PLDHashNumber h = 0; const NameTableKey* tableKey = static_cast(aKey); diff --git a/xpcom/glue/PLDHashTable.cpp b/xpcom/glue/PLDHashTable.cpp index fa121bbacd2d..c9d82af00f87 100644 --- a/xpcom/glue/PLDHashTable.cpp +++ b/xpcom/glue/PLDHashTable.cpp @@ -63,21 +63,19 @@ public: #endif /* static */ PLDHashNumber -PLDHashTable::HashStringKey(PLDHashTable* aTable, const void* aKey) +PLDHashTable::HashStringKey(const void* aKey) { return HashString(static_cast(aKey)); } /* static */ PLDHashNumber -PLDHashTable::HashVoidPtrKeyStub(PLDHashTable* aTable, const void* aKey) +PLDHashTable::HashVoidPtrKeyStub(const void* aKey) { return (PLDHashNumber)(ptrdiff_t)aKey >> 2; } /* static */ bool -PLDHashTable::MatchEntryStub(PLDHashTable* aTable, - const PLDHashEntryHdr* aEntry, - const void* aKey) +PLDHashTable::MatchEntryStub(const PLDHashEntryHdr* aEntry, const void* aKey) { const PLDHashEntryStub* stub = (const PLDHashEntryStub*)aEntry; @@ -85,9 +83,7 @@ PLDHashTable::MatchEntryStub(PLDHashTable* aTable, } /* static */ bool -PLDHashTable::MatchStringKey(PLDHashTable* aTable, - const PLDHashEntryHdr* aEntry, - const void* aKey) +PLDHashTable::MatchStringKey(const PLDHashEntryHdr* aEntry, const void* aKey) { const PLDHashEntryStub* stub = (const PLDHashEntryStub*)aEntry; @@ -355,7 +351,7 @@ PLDHashTable::SearchTable(const void* aKey, PLDHashNumber aKeyHash) // Hit: return entry. PLDHashMatchEntry matchEntry = mOps->matchEntry; if (MatchEntryKeyhash(entry, aKeyHash) && - matchEntry(this, entry, aKey)) { + matchEntry(entry, aKey)) { return entry; } @@ -389,7 +385,7 @@ PLDHashTable::SearchTable(const void* aKey, PLDHashNumber aKeyHash) } if (MatchEntryKeyhash(entry, aKeyHash) && - matchEntry(this, entry, aKey)) { + matchEntry(entry, aKey)) { return entry; } } @@ -501,7 +497,7 @@ PLDHashTable::ComputeKeyHash(const void* aKey) { MOZ_ASSERT(mEntryStore.Get()); - PLDHashNumber keyHash = mOps->hashKey(this, aKey); + PLDHashNumber keyHash = mOps->hashKey(aKey); keyHash *= kGoldenRatio; // Avoid 0 and 1 hash codes, they indicate free and removed entries. diff --git a/xpcom/glue/PLDHashTable.h b/xpcom/glue/PLDHashTable.h index 88a9f3ab5fa2..50bf5178745e 100644 --- a/xpcom/glue/PLDHashTable.h +++ b/xpcom/glue/PLDHashTable.h @@ -396,18 +396,15 @@ public: static const PLDHashTableOps* StubOps(); // The individual stub operations in StubOps(). - static PLDHashNumber HashVoidPtrKeyStub(PLDHashTable* aTable, - const void* aKey); - static bool MatchEntryStub(PLDHashTable* aTable, - const PLDHashEntryHdr* aEntry, const void* aKey); + static PLDHashNumber HashVoidPtrKeyStub(const void* aKey); + static bool MatchEntryStub(const PLDHashEntryHdr* aEntry, const void* aKey); static void MoveEntryStub(PLDHashTable* aTable, const PLDHashEntryHdr* aFrom, PLDHashEntryHdr* aTo); static void ClearEntryStub(PLDHashTable* aTable, PLDHashEntryHdr* aEntry); // Hash/match operations for tables holding C strings. - static PLDHashNumber HashStringKey(PLDHashTable* aTable, const void* aKey); - static bool MatchStringKey(PLDHashTable* aTable, - const PLDHashEntryHdr* aEntry, const void* aKey); + static PLDHashNumber HashStringKey(const void* aKey); + static bool MatchStringKey(const PLDHashEntryHdr* aEntry, const void* aKey); // This is an iterator for PLDHashtable. Assertions will detect some, but not // all, mid-iteration table modifications that might invalidate (e.g. @@ -555,15 +552,13 @@ private: PLDHashTable& operator=(const PLDHashTable& aOther) = delete; }; -// Compute the hash code for a given key to be looked up, added, or removed -// from aTable. A hash code may have any PLDHashNumber value. -typedef PLDHashNumber (*PLDHashHashKey)(PLDHashTable* aTable, - const void* aKey); +// Compute the hash code for a given key to be looked up, added, or removed. +// A hash code may have any PLDHashNumber value. +typedef PLDHashNumber (*PLDHashHashKey)(const void* aKey); -// Compare the key identifying aEntry in aTable with the provided key parameter. -// Return true if keys match, false otherwise. -typedef bool (*PLDHashMatchEntry)(PLDHashTable* aTable, - const PLDHashEntryHdr* aEntry, +// Compare the key identifying aEntry with the provided key parameter. Return +// true if keys match, false otherwise. +typedef bool (*PLDHashMatchEntry)(const PLDHashEntryHdr* aEntry, const void* aKey); // Copy the data starting at aFrom to the new entry storage at aTo. Do not add diff --git a/xpcom/glue/nsTHashtable.h b/xpcom/glue/nsTHashtable.h index 253b3b5716ad..ba359a51df11 100644 --- a/xpcom/glue/nsTHashtable.h +++ b/xpcom/glue/nsTHashtable.h @@ -303,11 +303,9 @@ public: protected: PLDHashTable mTable; - static const void* s_GetKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry); + static PLDHashNumber s_HashKey(const void* aKey); - static PLDHashNumber s_HashKey(PLDHashTable* aTable, const void* aKey); - - static bool s_MatchEntry(PLDHashTable* aTable, const PLDHashEntryHdr* aEntry, + static bool s_MatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey); static void s_CopyEntry(PLDHashTable* aTable, const PLDHashEntryHdr* aFrom, @@ -370,15 +368,14 @@ nsTHashtable::Ops() template PLDHashNumber -nsTHashtable::s_HashKey(PLDHashTable* aTable, const void* aKey) +nsTHashtable::s_HashKey(const void* aKey) { return EntryType::HashKey(static_cast(aKey)); } template bool -nsTHashtable::s_MatchEntry(PLDHashTable* aTable, - const PLDHashEntryHdr* aEntry, +nsTHashtable::s_MatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey) { return ((const EntryType*)aEntry)->KeyEquals( diff --git a/xpcom/tests/gtest/TestPLDHash.cpp b/xpcom/tests/gtest/TestPLDHash.cpp index 6d7150088cd4..4a68391c8fb3 100644 --- a/xpcom/tests/gtest/TestPLDHash.cpp +++ b/xpcom/tests/gtest/TestPLDHash.cpp @@ -157,7 +157,7 @@ TEST(PLDHashTableTest, LazyStorage) // GrowToMaxCapacity test because we insert the integers 0.., which means it's // collision-free. static PLDHashNumber -TrivialHash(PLDHashTable *table, const void *key) +TrivialHash(const void *key) { return (PLDHashNumber)(size_t)key; }