mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1121760 (part 6) - Move all remaining PL_DHash*() functions into PLDHashTable. r=poiru.
This commit is contained in:
parent
93fcb9414c
commit
ac3ae5e6c1
@ -210,8 +210,8 @@ NS_GetContentList(nsINode* aRootNode,
|
|||||||
{
|
{
|
||||||
ContentListHashtableHashKey,
|
ContentListHashtableHashKey,
|
||||||
ContentListHashtableMatchEntry,
|
ContentListHashtableMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub
|
PLDHashTable::ClearEntryStub
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize the hashtable if needed.
|
// Initialize the hashtable if needed.
|
||||||
@ -313,8 +313,8 @@ GetFuncStringContentList(nsINode* aRootNode,
|
|||||||
{
|
{
|
||||||
FuncStringContentListHashtableHashKey,
|
FuncStringContentListHashtableHashKey,
|
||||||
FuncStringContentListHashtableMatchEntry,
|
FuncStringContentListHashtableMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub
|
PLDHashTable::ClearEntryStub
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize the hashtable if needed.
|
// Initialize the hashtable if needed.
|
||||||
|
@ -508,9 +508,9 @@ nsContentUtils::Init()
|
|||||||
if (!sEventListenerManagersHash) {
|
if (!sEventListenerManagersHash) {
|
||||||
static const PLDHashTableOps hash_table_ops =
|
static const PLDHashTableOps hash_table_ops =
|
||||||
{
|
{
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
PL_DHashMatchEntryStub,
|
PLDHashTable::MatchEntryStub,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
EventListenerManagerHashClearEntry,
|
EventListenerManagerHashClearEntry,
|
||||||
EventListenerManagerHashInitEntry
|
EventListenerManagerHashInitEntry
|
||||||
};
|
};
|
||||||
|
@ -3956,9 +3956,9 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc)
|
|||||||
|
|
||||||
static const PLDHashTableOps hash_table_ops =
|
static const PLDHashTableOps hash_table_ops =
|
||||||
{
|
{
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
PL_DHashMatchEntryStub,
|
PLDHashTable::MatchEntryStub,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
SubDocClearEntry,
|
SubDocClearEntry,
|
||||||
SubDocInitEntry
|
SubDocInitEntry
|
||||||
};
|
};
|
||||||
|
@ -265,7 +265,7 @@ nsPropertyTable::PropertyList::PropertyList(nsIAtom *aName,
|
|||||||
void *aDtorData,
|
void *aDtorData,
|
||||||
bool aTransfer)
|
bool aTransfer)
|
||||||
: mName(aName),
|
: mName(aName),
|
||||||
mObjectValueMap(PL_DHashGetStubOps(), sizeof(PropertyListMapEntry)),
|
mObjectValueMap(PLDHashTable::StubOps(), sizeof(PropertyListMapEntry)),
|
||||||
mDtorFunc(aDtorFunc),
|
mDtorFunc(aDtorFunc),
|
||||||
mDtorData(aDtorData),
|
mDtorData(aDtorData),
|
||||||
mTransfer(aTransfer),
|
mTransfer(aTransfer),
|
||||||
|
@ -106,7 +106,7 @@ static const PLDHashTableOps hash_table_ops =
|
|||||||
{
|
{
|
||||||
GlobalNameHashHashKey,
|
GlobalNameHashHashKey,
|
||||||
GlobalNameHashMatchEntry,
|
GlobalNameHashMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
GlobalNameHashClearEntry,
|
GlobalNameHashClearEntry,
|
||||||
GlobalNameHashInitEntry
|
GlobalNameHashInitEntry
|
||||||
};
|
};
|
||||||
|
@ -400,7 +400,7 @@ CreateNPObjWrapperTable()
|
|||||||
}
|
}
|
||||||
|
|
||||||
sNPObjWrappers =
|
sNPObjWrappers =
|
||||||
new PLDHashTable(PL_DHashGetStubOps(), sizeof(NPObjWrapperHashEntry));
|
new PLDHashTable(PLDHashTable::StubOps(), sizeof(NPObjWrapperHashEntry));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,9 +752,9 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps gOps = {
|
static const PLDHashTableOps gOps = {
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
PL_DHashMatchEntryStub,
|
PLDHashTable::MatchEntryStub,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
ClearBroadcasterMapEntry,
|
ClearBroadcasterMapEntry,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
class nsContentSupportMap {
|
class nsContentSupportMap {
|
||||||
public:
|
public:
|
||||||
nsContentSupportMap() : mMap(PL_DHashGetStubOps(), sizeof(Entry)) { }
|
nsContentSupportMap() : mMap(PLDHashTable::StubOps(), sizeof(Entry)) { }
|
||||||
~nsContentSupportMap() { }
|
~nsContentSupportMap() { }
|
||||||
|
|
||||||
nsresult Put(nsIContent* aElement, nsTemplateMatch* aMatch) {
|
nsresult Put(nsIContent* aElement, nsTemplateMatch* aMatch) {
|
||||||
|
@ -19,7 +19,7 @@ protected:
|
|||||||
PLDHashTable mTable;
|
PLDHashTable mTable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
nsTemplateMap() : mTable(PL_DHashGetStubOps(), sizeof(Entry)) { }
|
nsTemplateMap() : mTable(PLDHashTable::StubOps(), sizeof(Entry)) { }
|
||||||
|
|
||||||
~nsTemplateMap() { }
|
~nsTemplateMap() { }
|
||||||
|
|
||||||
|
@ -630,7 +630,7 @@ public:
|
|||||||
StringHash,
|
StringHash,
|
||||||
HashMatchEntry,
|
HashMatchEntry,
|
||||||
MoveEntry,
|
MoveEntry,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ Native2WrappedNativeMap::newMap(int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Native2WrappedNativeMap::Native2WrappedNativeMap(int length)
|
Native2WrappedNativeMap::Native2WrappedNativeMap(int length)
|
||||||
: mTable(new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length))
|
: mTable(new PLDHashTable(PLDHashTable::StubOps(), sizeof(Entry), length))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,8 +201,8 @@ const struct PLDHashTableOps IID2WrappedJSClassMap::Entry::sOps =
|
|||||||
{
|
{
|
||||||
HashIIDPtrKey,
|
HashIIDPtrKey,
|
||||||
MatchIIDPtrKey,
|
MatchIIDPtrKey,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub
|
PLDHashTable::ClearEntryStub
|
||||||
};
|
};
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -229,8 +229,8 @@ const struct PLDHashTableOps IID2NativeInterfaceMap::Entry::sOps =
|
|||||||
{
|
{
|
||||||
HashIIDPtrKey,
|
HashIIDPtrKey,
|
||||||
MatchIIDPtrKey,
|
MatchIIDPtrKey,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub
|
PLDHashTable::ClearEntryStub
|
||||||
};
|
};
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -273,7 +273,7 @@ ClassInfo2NativeSetMap::newMap(int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ClassInfo2NativeSetMap::ClassInfo2NativeSetMap(int length)
|
ClassInfo2NativeSetMap::ClassInfo2NativeSetMap(int length)
|
||||||
: mTable(new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length))
|
: mTable(new PLDHashTable(PLDHashTable::StubOps(), sizeof(Entry), length))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ ClassInfo2WrappedNativeProtoMap::newMap(int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ClassInfo2WrappedNativeProtoMap::ClassInfo2WrappedNativeProtoMap(int length)
|
ClassInfo2WrappedNativeProtoMap::ClassInfo2WrappedNativeProtoMap(int length)
|
||||||
: mTable(new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length))
|
: mTable(new PLDHashTable(PLDHashTable::StubOps(), sizeof(Entry), length))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,8 +401,8 @@ const struct PLDHashTableOps NativeSetMap::Entry::sOps =
|
|||||||
{
|
{
|
||||||
HashNativeKey,
|
HashNativeKey,
|
||||||
Match,
|
Match,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub
|
PLDHashTable::ClearEntryStub
|
||||||
};
|
};
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -456,7 +456,7 @@ const struct PLDHashTableOps IID2ThisTranslatorMap::Entry::sOps =
|
|||||||
{
|
{
|
||||||
HashIIDPtrKey,
|
HashIIDPtrKey,
|
||||||
Match,
|
Match,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
Clear
|
Clear
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -527,8 +527,8 @@ const struct PLDHashTableOps XPCNativeScriptableSharedMap::Entry::sOps =
|
|||||||
{
|
{
|
||||||
Hash,
|
Hash,
|
||||||
Match,
|
Match,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub
|
PLDHashTable::ClearEntryStub
|
||||||
};
|
};
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@ -585,7 +585,7 @@ XPCWrappedNativeProtoMap::newMap(int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
XPCWrappedNativeProtoMap::XPCWrappedNativeProtoMap(int length)
|
XPCWrappedNativeProtoMap::XPCWrappedNativeProtoMap(int length)
|
||||||
: mTable(new PLDHashTable(PL_DHashGetStubOps(), sizeof(PLDHashEntryStub),
|
: mTable(new PLDHashTable(PLDHashTable::StubOps(), sizeof(PLDHashEntryStub),
|
||||||
length))
|
length))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
// Note that most of the declarations for hash table entries begin with
|
// Note that most of the declarations for hash table entries begin with
|
||||||
// a pointer to something or another. This makes them look enough like
|
// a pointer to something or another. This makes them look enough like
|
||||||
// the PLDHashEntryStub struct that the default OPs (PL_DHashGetStubOps())
|
// the PLDHashEntryStub struct that the default ops (PLDHashTable::StubOps())
|
||||||
// just do the right thing for most of our needs.
|
// just do the right thing for most of our needs.
|
||||||
|
|
||||||
// no virtuals in the maps - all the common stuff inlined
|
// no virtuals in the maps - all the common stuff inlined
|
||||||
|
@ -69,10 +69,10 @@ PlaceholderMapMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps PlaceholderMapOps = {
|
static const PLDHashTableOps PlaceholderMapOps = {
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
PlaceholderMapMatchEntry,
|
PlaceholderMapMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ RuleHash_NameSpaceTable_MatchEntry(PLDHashTable *table,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps RuleHash_TagTable_Ops = {
|
static const PLDHashTableOps RuleHash_TagTable_Ops = {
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
RuleHash_TagTable_MatchEntry,
|
RuleHash_TagTable_MatchEntry,
|
||||||
RuleHash_TagTable_MoveEntry,
|
RuleHash_TagTable_MoveEntry,
|
||||||
RuleHash_TagTable_ClearEntry,
|
RuleHash_TagTable_ClearEntry,
|
||||||
@ -369,7 +369,7 @@ static const PLDHashTableOps RuleHash_TagTable_Ops = {
|
|||||||
// Case-sensitive ops.
|
// Case-sensitive ops.
|
||||||
static const RuleHashTableOps RuleHash_ClassTable_CSOps = {
|
static const RuleHashTableOps RuleHash_ClassTable_CSOps = {
|
||||||
{
|
{
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
RuleHash_CSMatchEntry,
|
RuleHash_CSMatchEntry,
|
||||||
RuleHash_MoveEntry,
|
RuleHash_MoveEntry,
|
||||||
RuleHash_ClearEntry,
|
RuleHash_ClearEntry,
|
||||||
@ -393,7 +393,7 @@ static const RuleHashTableOps RuleHash_ClassTable_CIOps = {
|
|||||||
// Case-sensitive ops.
|
// Case-sensitive ops.
|
||||||
static const RuleHashTableOps RuleHash_IdTable_CSOps = {
|
static const RuleHashTableOps RuleHash_IdTable_CSOps = {
|
||||||
{
|
{
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
RuleHash_CSMatchEntry,
|
RuleHash_CSMatchEntry,
|
||||||
RuleHash_MoveEntry,
|
RuleHash_MoveEntry,
|
||||||
RuleHash_ClearEntry,
|
RuleHash_ClearEntry,
|
||||||
@ -850,8 +850,8 @@ AtomSelector_GetKey(PLDHashTable *table, const PLDHashEntryHdr *hdr)
|
|||||||
|
|
||||||
// Case-sensitive ops.
|
// Case-sensitive ops.
|
||||||
static const PLDHashTableOps AtomSelector_CSOps = {
|
static const PLDHashTableOps AtomSelector_CSOps = {
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
PL_DHashMatchEntryStub,
|
PLDHashTable::MatchEntryStub,
|
||||||
AtomSelector_MoveEntry,
|
AtomSelector_MoveEntry,
|
||||||
AtomSelector_ClearEntry,
|
AtomSelector_ClearEntry,
|
||||||
AtomSelector_InitEntry
|
AtomSelector_InitEntry
|
||||||
@ -3516,8 +3516,8 @@ InitWeightEntry(PLDHashEntryHdr *hdr, const void *key)
|
|||||||
static const PLDHashTableOps gRulesByWeightOps = {
|
static const PLDHashTableOps gRulesByWeightOps = {
|
||||||
HashIntKey,
|
HashIntKey,
|
||||||
MatchWeightEntry,
|
MatchWeightEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
InitWeightEntry
|
InitWeightEntry
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ MappedAttrTable_MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
|||||||
static const PLDHashTableOps MappedAttrTable_Ops = {
|
static const PLDHashTableOps MappedAttrTable_Ops = {
|
||||||
MappedAttrTable_HashKey,
|
MappedAttrTable_HashKey,
|
||||||
MappedAttrTable_MatchEntry,
|
MappedAttrTable_MatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
MappedAttrTable_ClearEntry,
|
MappedAttrTable_ClearEntry,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
@ -222,7 +222,7 @@ LangRuleTable_InitEntry(PLDHashEntryHdr *hdr, const void *key)
|
|||||||
static const PLDHashTableOps LangRuleTable_Ops = {
|
static const PLDHashTableOps LangRuleTable_Ops = {
|
||||||
LangRuleTable_HashKey,
|
LangRuleTable_HashKey,
|
||||||
LangRuleTable_MatchEntry,
|
LangRuleTable_MatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
LangRuleTable_ClearEntry,
|
LangRuleTable_ClearEntry,
|
||||||
LangRuleTable_InitEntry
|
LangRuleTable_InitEntry
|
||||||
};
|
};
|
||||||
|
@ -104,7 +104,7 @@ nsRuleNode::ChildrenHashHashKey(PLDHashTable *aTable, const void *aKey)
|
|||||||
static_cast<const nsRuleNode::Key*>(aKey);
|
static_cast<const nsRuleNode::Key*>(aKey);
|
||||||
// Disagreement on importance and level for the same rule is extremely
|
// Disagreement on importance and level for the same rule is extremely
|
||||||
// rare, so hash just on the rule.
|
// rare, so hash just on the rule.
|
||||||
return PL_DHashVoidPtrKeyStub(aTable, key->mRule);
|
return PLDHashTable::HashVoidPtrKeyStub(aTable, key->mRule);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool
|
/* static */ bool
|
||||||
@ -127,8 +127,8 @@ nsRuleNode::ChildrenHashOps = {
|
|||||||
// large size allocations.
|
// large size allocations.
|
||||||
ChildrenHashHashKey,
|
ChildrenHashHashKey,
|
||||||
ChildrenHashMatchEntry,
|
ChildrenHashMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ SpanningCellSorter::~SpanningCellSorter()
|
|||||||
SpanningCellSorter::HashTableOps = {
|
SpanningCellSorter::HashTableOps = {
|
||||||
HashTableHashKey,
|
HashTableHashKey,
|
||||||
HashTableMatchEntry,
|
HashTableMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,9 +80,9 @@ static bool gShouldCleanupDeadNodes = false;
|
|||||||
|
|
||||||
|
|
||||||
static PLDHashTableOps pref_HashTableOps = {
|
static PLDHashTableOps pref_HashTableOps = {
|
||||||
PL_DHashStringKey,
|
PLDHashTable::HashStringKey,
|
||||||
matchPrefEntry,
|
matchPrefEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
clearPrefEntry,
|
clearPrefEntry,
|
||||||
nullptr,
|
nullptr,
|
||||||
};
|
};
|
||||||
|
@ -88,9 +88,9 @@ RequestHashInitEntry(PLDHashEntryHdr *entry, const void *key)
|
|||||||
|
|
||||||
static const PLDHashTableOps sRequestHashOps =
|
static const PLDHashTableOps sRequestHashOps =
|
||||||
{
|
{
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
RequestHashMatchEntry,
|
RequestHashMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
RequestHashClearEntry,
|
RequestHashClearEntry,
|
||||||
RequestHashInitEntry
|
RequestHashInitEntry
|
||||||
};
|
};
|
||||||
|
@ -68,9 +68,9 @@ public:
|
|||||||
|
|
||||||
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
||||||
{
|
{
|
||||||
// PL_DHashStringKey doesn't use the table parameter, so we can safely
|
// PLDHashTable::HashStringKey doesn't use the table parameter, so we can
|
||||||
// pass nullptr
|
// safely pass nullptr
|
||||||
return PL_DHashStringKey(nullptr, aKey);
|
return PLDHashTable::HashStringKey(nullptr, aKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { ALLOW_MEMMOVE = true };
|
enum { ALLOW_MEMMOVE = true };
|
||||||
|
@ -85,8 +85,8 @@ StringCompare(PLDHashTable *table, const PLDHashEntryHdr *entry,
|
|||||||
static const PLDHashTableOps ops = {
|
static const PLDHashTableOps ops = {
|
||||||
StringHash,
|
StringHash,
|
||||||
StringCompare,
|
StringCompare,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,18 +50,18 @@ static PLDHashNumber
|
|||||||
|
|
||||||
|
|
||||||
static const PLDHashTableOps EntityToUnicodeOps = {
|
static const PLDHashTableOps EntityToUnicodeOps = {
|
||||||
PL_DHashStringKey,
|
PLDHashTable::HashStringKey,
|
||||||
matchNodeString,
|
matchNodeString,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr,
|
nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const PLDHashTableOps UnicodeToEntityOps = {
|
static const PLDHashTableOps UnicodeToEntityOps = {
|
||||||
hashUnicodeValue,
|
hashUnicodeValue,
|
||||||
matchNodeUnicode,
|
matchNodeUnicode,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr,
|
nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ Assertion::Assertion(nsIRDFResource* aSource)
|
|||||||
NS_ADDREF(mSource);
|
NS_ADDREF(mSource);
|
||||||
|
|
||||||
u.hash.mPropertyHash =
|
u.hash.mPropertyHash =
|
||||||
new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry));
|
new PLDHashTable(PLDHashTable::StubOps(), sizeof(Entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
Assertion::Assertion(nsIRDFResource* aSource,
|
Assertion::Assertion(nsIRDFResource* aSource,
|
||||||
@ -734,8 +734,8 @@ NS_NewRDFInMemoryDataSource(nsISupports* aOuter, const nsIID& aIID, void** aResu
|
|||||||
|
|
||||||
|
|
||||||
InMemoryDataSource::InMemoryDataSource(nsISupports* aOuter)
|
InMemoryDataSource::InMemoryDataSource(nsISupports* aOuter)
|
||||||
: mForwardArcs(PL_DHashGetStubOps(), sizeof(Entry))
|
: mForwardArcs(PLDHashTable::StubOps(), sizeof(Entry))
|
||||||
, mReverseArcs(PL_DHashGetStubOps(), sizeof(Entry))
|
, mReverseArcs(PLDHashTable::StubOps(), sizeof(Entry))
|
||||||
, mNumObservers(0)
|
, mNumObservers(0)
|
||||||
, mReadCount(0)
|
, mReadCount(0)
|
||||||
{
|
{
|
||||||
|
@ -141,8 +141,8 @@ struct ResourceHashEntry : public PLDHashEntryHdr {
|
|||||||
static const PLDHashTableOps gResourceTableOps = {
|
static const PLDHashTableOps gResourceTableOps = {
|
||||||
ResourceHashEntry::HashKey,
|
ResourceHashEntry::HashKey,
|
||||||
ResourceHashEntry::MatchEntry,
|
ResourceHashEntry::MatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -176,8 +176,8 @@ struct LiteralHashEntry : public PLDHashEntryHdr {
|
|||||||
static const PLDHashTableOps gLiteralTableOps = {
|
static const PLDHashTableOps gLiteralTableOps = {
|
||||||
LiteralHashEntry::HashKey,
|
LiteralHashEntry::HashKey,
|
||||||
LiteralHashEntry::MatchEntry,
|
LiteralHashEntry::MatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -210,8 +210,8 @@ struct IntHashEntry : public PLDHashEntryHdr {
|
|||||||
static const PLDHashTableOps gIntTableOps = {
|
static const PLDHashTableOps gIntTableOps = {
|
||||||
IntHashEntry::HashKey,
|
IntHashEntry::HashKey,
|
||||||
IntHashEntry::MatchEntry,
|
IntHashEntry::MatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -248,8 +248,8 @@ struct DateHashEntry : public PLDHashEntryHdr {
|
|||||||
static const PLDHashTableOps gDateTableOps = {
|
static const PLDHashTableOps gDateTableOps = {
|
||||||
DateHashEntry::HashKey,
|
DateHashEntry::HashKey,
|
||||||
DateHashEntry::MatchEntry,
|
DateHashEntry::MatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -365,8 +365,8 @@ struct BlobHashEntry : public PLDHashEntryHdr {
|
|||||||
static const PLDHashTableOps gBlobTableOps = {
|
static const PLDHashTableOps gBlobTableOps = {
|
||||||
BlobHashEntry::HashKey,
|
BlobHashEntry::HashKey,
|
||||||
BlobHashEntry::MatchEntry,
|
BlobHashEntry::MatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -107,9 +107,9 @@ class nsCertOverrideEntry final : public PLDHashEntryHdr
|
|||||||
|
|
||||||
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
||||||
{
|
{
|
||||||
// PL_DHashStringKey doesn't use the table parameter, so we can safely
|
// PLDHashTable::HashStringKey doesn't use the table parameter, so we can
|
||||||
// pass nullptr
|
// safely pass nullptr
|
||||||
return PL_DHashStringKey(nullptr, aKey);
|
return PLDHashTable::HashStringKey(nullptr, aKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { ALLOW_MEMMOVE = false };
|
enum { ALLOW_MEMMOVE = false };
|
||||||
|
@ -84,9 +84,9 @@ CompareCacheClearEntry(PLDHashTable *table, PLDHashEntryHdr *hdr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps gMapOps = {
|
static const PLDHashTableOps gMapOps = {
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
CompareCacheMatchEntry,
|
CompareCacheMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
CompareCacheClearEntry,
|
CompareCacheClearEntry,
|
||||||
CompareCacheInitEntry
|
CompareCacheInitEntry
|
||||||
};
|
};
|
||||||
|
@ -87,9 +87,9 @@ class nsClientAuthRememberEntry final : public PLDHashEntryHdr
|
|||||||
|
|
||||||
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
static PLDHashNumber HashKey(KeyTypePointer aKey)
|
||||||
{
|
{
|
||||||
// PL_DHashStringKey doesn't use the table parameter, so we can safely
|
// PLDHashTable::HashStringKey doesn't use the table parameter, so we can
|
||||||
// pass nullptr
|
// safely pass nullptr
|
||||||
return PL_DHashStringKey(nullptr, aKey);
|
return PLDHashTable::HashStringKey(nullptr, aKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { ALLOW_MEMMOVE = false };
|
enum { ALLOW_MEMMOVE = false };
|
||||||
|
@ -29,10 +29,10 @@ ObjectSetInitEntry(PLDHashEntryHdr *hdr, const void *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps gSetOps = {
|
static const PLDHashTableOps gSetOps = {
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
ObjectSetMatchEntry,
|
ObjectSetMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
ObjectSetInitEntry
|
ObjectSetInitEntry
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,10 +70,10 @@ RequestMapInitEntry(PLDHashEntryHdr *hdr, const void *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps gMapOps = {
|
static const PLDHashTableOps gMapOps = {
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
RequestMapMatchEntry,
|
RequestMapMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
RequestMapInitEntry
|
RequestMapInitEntry
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -95,9 +95,9 @@ class nsDefaultComparator <nsDocLoader::nsListenerInfo, nsIWebProgressListener*>
|
|||||||
|
|
||||||
/* static */ const PLDHashTableOps nsDocLoader::sRequestInfoHashOps =
|
/* static */ const PLDHashTableOps nsDocLoader::sRequestInfoHashOps =
|
||||||
{
|
{
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
PL_DHashMatchEntryStub,
|
PLDHashTable::MatchEntryStub,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
nsDocLoader::RequestInfoHashClearEntry,
|
nsDocLoader::RequestInfoHashClearEntry,
|
||||||
nsDocLoader::RequestInfoHashInitEntry
|
nsDocLoader::RequestInfoHashInitEntry
|
||||||
};
|
};
|
||||||
|
@ -803,10 +803,10 @@ PtrToNodeMatchEntry(PLDHashTable* aTable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static PLDHashTableOps PtrNodeOps = {
|
static PLDHashTableOps PtrNodeOps = {
|
||||||
PL_DHashVoidPtrKeyStub,
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
PtrToNodeMatchEntry,
|
PtrToNodeMatchEntry,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ AtomTableInitEntry(PLDHashEntryHdr* aEntry, const void* aKey)
|
|||||||
static const PLDHashTableOps AtomTableOps = {
|
static const PLDHashTableOps AtomTableOps = {
|
||||||
AtomTableGetHash,
|
AtomTableGetHash,
|
||||||
AtomTableMatchKey,
|
AtomTableMatchKey,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
AtomTableClearEntry,
|
AtomTableClearEntry,
|
||||||
AtomTableInitEntry
|
AtomTableInitEntry
|
||||||
};
|
};
|
||||||
|
@ -51,10 +51,10 @@ ArenaStrdup(const nsAFlatCString& aString, PLArenaPool* aArena)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static const struct PLDHashTableOps property_HashTableOps = {
|
static const struct PLDHashTableOps property_HashTableOps = {
|
||||||
PL_DHashStringKey,
|
PLDHashTable::HashStringKey,
|
||||||
PL_DHashMatchStringKey,
|
PLDHashTable::MatchStringKey,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr,
|
nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ matchNameKeysCaseInsensitive(PLDHashTable*, const PLDHashEntryHdr* aHdr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* caseInsensitiveHashKey is just like PL_DHashStringKey except it
|
* caseInsensitiveHashKey is just like PLDHashTable::HashStringKey except it
|
||||||
* uses (*s & ~0x20) instead of simply *s. This means that "aFOO" and
|
* uses (*s & ~0x20) instead of simply *s. This means that "aFOO" and
|
||||||
* "afoo" and "aFoo" will all hash to the same thing. It also means
|
* "afoo" and "aFoo" will all hash to the same thing. It also means
|
||||||
* that some strings that aren't case-insensensitively equal will hash
|
* that some strings that aren't case-insensensitively equal will hash
|
||||||
@ -96,8 +96,8 @@ caseInsensitiveStringHashKey(PLDHashTable* aTable, const void* aKey)
|
|||||||
static const struct PLDHashTableOps nametable_CaseInsensitiveHashTableOps = {
|
static const struct PLDHashTableOps nametable_CaseInsensitiveHashTableOps = {
|
||||||
caseInsensitiveStringHashKey,
|
caseInsensitiveStringHashKey,
|
||||||
matchNameKeysCaseInsensitive,
|
matchNameKeysCaseInsensitive,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
nullptr,
|
nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ nsTHashtable<EntryType>::Ops()
|
|||||||
{
|
{
|
||||||
s_HashKey,
|
s_HashKey,
|
||||||
s_MatchEntry,
|
s_MatchEntry,
|
||||||
EntryType::ALLOW_MEMMOVE ? ::PL_DHashMoveEntryStub : s_CopyEntry,
|
EntryType::ALLOW_MEMMOVE ? PLDHashTable::MoveEntryStub : s_CopyEntry,
|
||||||
s_ClearEntry,
|
s_ClearEntry,
|
||||||
s_InitEntry
|
s_InitEntry
|
||||||
};
|
};
|
||||||
|
@ -62,32 +62,32 @@ public:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PLDHashNumber
|
/* static */ PLDHashNumber
|
||||||
PL_DHashStringKey(PLDHashTable* aTable, const void* aKey)
|
PLDHashTable::HashStringKey(PLDHashTable* aTable, const void* aKey)
|
||||||
{
|
{
|
||||||
return HashString(static_cast<const char*>(aKey));
|
return HashString(static_cast<const char*>(aKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
PLDHashNumber
|
/* static */ PLDHashNumber
|
||||||
PL_DHashVoidPtrKeyStub(PLDHashTable* aTable, const void* aKey)
|
PLDHashTable::HashVoidPtrKeyStub(PLDHashTable* aTable, const void* aKey)
|
||||||
{
|
{
|
||||||
return (PLDHashNumber)(ptrdiff_t)aKey >> 2;
|
return (PLDHashNumber)(ptrdiff_t)aKey >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
/* static */ bool
|
||||||
PL_DHashMatchEntryStub(PLDHashTable* aTable,
|
PLDHashTable::MatchEntryStub(PLDHashTable* aTable,
|
||||||
const PLDHashEntryHdr* aEntry,
|
const PLDHashEntryHdr* aEntry,
|
||||||
const void* aKey)
|
const void* aKey)
|
||||||
{
|
{
|
||||||
const PLDHashEntryStub* stub = (const PLDHashEntryStub*)aEntry;
|
const PLDHashEntryStub* stub = (const PLDHashEntryStub*)aEntry;
|
||||||
|
|
||||||
return stub->key == aKey;
|
return stub->key == aKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
/* static */ bool
|
||||||
PL_DHashMatchStringKey(PLDHashTable* aTable,
|
PLDHashTable::MatchStringKey(PLDHashTable* aTable,
|
||||||
const PLDHashEntryHdr* aEntry,
|
const PLDHashEntryHdr* aEntry,
|
||||||
const void* aKey)
|
const void* aKey)
|
||||||
{
|
{
|
||||||
const PLDHashEntryStub* stub = (const PLDHashEntryStub*)aEntry;
|
const PLDHashEntryStub* stub = (const PLDHashEntryStub*)aEntry;
|
||||||
|
|
||||||
@ -97,45 +97,32 @@ PL_DHashMatchStringKey(PLDHashTable* aTable,
|
|||||||
strcmp((const char*)stub->key, (const char*)aKey) == 0);
|
strcmp((const char*)stub->key, (const char*)aKey) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ALWAYS_INLINE void
|
/* static */ void
|
||||||
PLDHashTable::MoveEntryStub(const PLDHashEntryHdr* aFrom,
|
PLDHashTable::MoveEntryStub(PLDHashTable* aTable,
|
||||||
|
const PLDHashEntryHdr* aFrom,
|
||||||
PLDHashEntryHdr* aTo)
|
PLDHashEntryHdr* aTo)
|
||||||
{
|
{
|
||||||
memcpy(aTo, aFrom, mEntrySize);
|
memcpy(aTo, aFrom, aTable->mEntrySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* static */ void
|
||||||
PL_DHashMoveEntryStub(PLDHashTable* aTable,
|
PLDHashTable::ClearEntryStub(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
|
||||||
const PLDHashEntryHdr* aFrom,
|
|
||||||
PLDHashEntryHdr* aTo)
|
|
||||||
{
|
{
|
||||||
aTable->MoveEntryStub(aFrom, aTo);
|
memset(aEntry, 0, aTable->mEntrySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ALWAYS_INLINE void
|
static const PLDHashTableOps gStubOps = {
|
||||||
PLDHashTable::ClearEntryStub(PLDHashEntryHdr* aEntry)
|
PLDHashTable::HashVoidPtrKeyStub,
|
||||||
{
|
PLDHashTable::MatchEntryStub,
|
||||||
memset(aEntry, 0, mEntrySize);
|
PLDHashTable::MoveEntryStub,
|
||||||
}
|
PLDHashTable::ClearEntryStub,
|
||||||
|
|
||||||
void
|
|
||||||
PL_DHashClearEntryStub(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
|
|
||||||
{
|
|
||||||
aTable->ClearEntryStub(aEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const PLDHashTableOps stub_ops = {
|
|
||||||
PL_DHashVoidPtrKeyStub,
|
|
||||||
PL_DHashMatchEntryStub,
|
|
||||||
PL_DHashMoveEntryStub,
|
|
||||||
PL_DHashClearEntryStub,
|
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
const PLDHashTableOps*
|
/* static */ const PLDHashTableOps*
|
||||||
PL_DHashGetStubOps(void)
|
PLDHashTable::StubOps()
|
||||||
{
|
{
|
||||||
return &stub_ops;
|
return &gStubOps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -398,9 +398,24 @@ public:
|
|||||||
void MarkImmutable();
|
void MarkImmutable();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void MoveEntryStub(const PLDHashEntryHdr* aFrom, PLDHashEntryHdr* aTo);
|
// If you use PLDHashEntryStub or a subclass of it as your entry struct, and
|
||||||
|
// if your entries move via memcpy and clear via memset(0), you can use these
|
||||||
|
// stub operations.
|
||||||
|
static const PLDHashTableOps* StubOps();
|
||||||
|
|
||||||
void ClearEntryStub(PLDHashEntryHdr* aEntry);
|
// 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 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);
|
||||||
|
|
||||||
// This is an iterator for PLDHashtable. Assertions will detect some, but not
|
// This is an iterator for PLDHashtable. Assertions will detect some, but not
|
||||||
// all, mid-iteration table modifications that might invalidate (e.g.
|
// all, mid-iteration table modifications that might invalidate (e.g.
|
||||||
@ -582,42 +597,10 @@ struct PLDHashTableOps
|
|||||||
PLDHashInitEntry initEntry;
|
PLDHashInitEntry initEntry;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Default implementations for the above mOps.
|
// A minimal entry is a subclass of PLDHashEntryHdr and has a void* key pointer.
|
||||||
|
|
||||||
PLDHashNumber
|
|
||||||
PL_DHashStringKey(PLDHashTable* aTable, const void* aKey);
|
|
||||||
|
|
||||||
// A minimal entry is a subclass of PLDHashEntryHdr and has void key pointer.
|
|
||||||
struct PLDHashEntryStub : public PLDHashEntryHdr
|
struct PLDHashEntryStub : public PLDHashEntryHdr
|
||||||
{
|
{
|
||||||
const void* key;
|
const void* key;
|
||||||
};
|
};
|
||||||
|
|
||||||
PLDHashNumber
|
|
||||||
PL_DHashVoidPtrKeyStub(PLDHashTable* aTable, const void* aKey);
|
|
||||||
|
|
||||||
bool
|
|
||||||
PL_DHashMatchEntryStub(PLDHashTable* aTable,
|
|
||||||
const PLDHashEntryHdr* aEntry,
|
|
||||||
const void* aKey);
|
|
||||||
|
|
||||||
bool
|
|
||||||
PL_DHashMatchStringKey(PLDHashTable* aTable,
|
|
||||||
const PLDHashEntryHdr* aEntry,
|
|
||||||
const void* aKey);
|
|
||||||
|
|
||||||
void
|
|
||||||
PL_DHashMoveEntryStub(PLDHashTable* aTable,
|
|
||||||
const PLDHashEntryHdr* aFrom,
|
|
||||||
PLDHashEntryHdr* aTo);
|
|
||||||
|
|
||||||
void
|
|
||||||
PL_DHashClearEntryStub(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
|
|
||||||
|
|
||||||
// If you use PLDHashEntryStub or a subclass of it as your entry struct, and
|
|
||||||
// if your entries move via memcpy and clear via memset(0), you can use these
|
|
||||||
// stub operations.
|
|
||||||
const PLDHashTableOps*
|
|
||||||
PL_DHashGetStubOps(void);
|
|
||||||
|
|
||||||
#endif /* pldhash_h___ */
|
#endif /* pldhash_h___ */
|
||||||
|
@ -77,7 +77,7 @@ TestCrashyOperation(void (*aCrashyOperation)())
|
|||||||
void
|
void
|
||||||
InitCapacityOk_InitialLengthTooBig()
|
InitCapacityOk_InitialLengthTooBig()
|
||||||
{
|
{
|
||||||
PLDHashTable t(PL_DHashGetStubOps(), sizeof(PLDHashEntryStub),
|
PLDHashTable t(PLDHashTable::StubOps(), sizeof(PLDHashEntryStub),
|
||||||
PLDHashTable::kMaxInitialLength + 1);
|
PLDHashTable::kMaxInitialLength + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ InitCapacityOk_InitialEntryStoreTooBig()
|
|||||||
// Try the smallest disallowed power-of-two entry store size, which is 2^32
|
// Try the smallest disallowed power-of-two entry store size, which is 2^32
|
||||||
// bytes (which overflows to 0). (Note that the 2^23 *length* gets converted
|
// bytes (which overflows to 0). (Note that the 2^23 *length* gets converted
|
||||||
// to a 2^24 *capacity*.)
|
// to a 2^24 *capacity*.)
|
||||||
PLDHashTable t(PL_DHashGetStubOps(), (uint32_t)1 << 23, (uint32_t)1 << 8);
|
PLDHashTable t(PLDHashTable::StubOps(), (uint32_t)1 << 23, (uint32_t)1 << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PLDHashTableTest, InitCapacityOk)
|
TEST(PLDHashTableTest, InitCapacityOk)
|
||||||
@ -95,12 +95,12 @@ TEST(PLDHashTableTest, InitCapacityOk)
|
|||||||
// Try the largest allowed capacity. With kMaxCapacity==1<<26, this
|
// Try the largest allowed capacity. With kMaxCapacity==1<<26, this
|
||||||
// would allocate (if we added an element) 0.5GB of entry store on 32-bit
|
// would allocate (if we added an element) 0.5GB of entry store on 32-bit
|
||||||
// platforms and 1GB on 64-bit platforms.
|
// platforms and 1GB on 64-bit platforms.
|
||||||
PLDHashTable t1(PL_DHashGetStubOps(), sizeof(PLDHashEntryStub),
|
PLDHashTable t1(PLDHashTable::StubOps(), sizeof(PLDHashEntryStub),
|
||||||
PLDHashTable::kMaxInitialLength);
|
PLDHashTable::kMaxInitialLength);
|
||||||
|
|
||||||
// Try the largest allowed power-of-two entry store size, which is 2^31 bytes
|
// Try the largest allowed power-of-two entry store size, which is 2^31 bytes
|
||||||
// (Note that the 2^23 *length* gets converted to a 2^24 *capacity*.)
|
// (Note that the 2^23 *length* gets converted to a 2^24 *capacity*.)
|
||||||
PLDHashTable t2(PL_DHashGetStubOps(), (uint32_t)1 << 23, (uint32_t)1 << 7);
|
PLDHashTable t2(PLDHashTable::StubOps(), (uint32_t)1 << 23, (uint32_t)1 << 7);
|
||||||
|
|
||||||
// Try a too-large capacity (which aborts).
|
// Try a too-large capacity (which aborts).
|
||||||
TestCrashyOperation(InitCapacityOk_InitialLengthTooBig);
|
TestCrashyOperation(InitCapacityOk_InitialLengthTooBig);
|
||||||
@ -117,7 +117,7 @@ TEST(PLDHashTableTest, InitCapacityOk)
|
|||||||
|
|
||||||
TEST(PLDHashTableTest, LazyStorage)
|
TEST(PLDHashTableTest, LazyStorage)
|
||||||
{
|
{
|
||||||
PLDHashTable t(PL_DHashGetStubOps(), sizeof(PLDHashEntryStub));
|
PLDHashTable t(PLDHashTable::StubOps(), sizeof(PLDHashEntryStub));
|
||||||
|
|
||||||
// PLDHashTable allocates entry storage lazily. Check that all the non-add
|
// PLDHashTable allocates entry storage lazily. Check that all the non-add
|
||||||
// operations work appropriately when the table is empty and the storage
|
// operations work appropriately when the table is empty and the storage
|
||||||
@ -158,9 +158,9 @@ TrivialInitEntry(PLDHashEntryHdr* aEntry, const void* aKey)
|
|||||||
|
|
||||||
static const PLDHashTableOps trivialOps = {
|
static const PLDHashTableOps trivialOps = {
|
||||||
TrivialHash,
|
TrivialHash,
|
||||||
PL_DHashMatchEntryStub,
|
PLDHashTable::MatchEntryStub,
|
||||||
PL_DHashMoveEntryStub,
|
PLDHashTable::MoveEntryStub,
|
||||||
PL_DHashClearEntryStub,
|
PLDHashTable::ClearEntryStub,
|
||||||
TrivialInitEntry
|
TrivialInitEntry
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user