mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1050035 (part 3) - Remove PL_NewDHashTable() and PL_DHashTableDestroy(). r=froydnj.
Because they are now just equivalent to |new PLDHashTable()| + PL_DHashTableInit() and PL_DHashTableFinish(t) + |delete t|, respectively. They're only used in a handful of places and obscure things more than they clarify -- I only recently worked out exactly how they different from Init() and Finish().
This commit is contained in:
parent
a5bbfabc46
commit
3aa6fd7b3d
@ -1715,8 +1715,8 @@ nsDocument::~nsDocument()
|
||||
// Kill the subdocument map, doing this will release its strong
|
||||
// references, if any.
|
||||
if (mSubDocuments) {
|
||||
PL_DHashTableDestroy(mSubDocuments);
|
||||
|
||||
PL_DHashTableFinish(mSubDocuments);
|
||||
delete mSubDocuments;
|
||||
mSubDocuments = nullptr;
|
||||
}
|
||||
|
||||
@ -2126,7 +2126,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||
}
|
||||
|
||||
if (tmp->mSubDocuments) {
|
||||
PL_DHashTableDestroy(tmp->mSubDocuments);
|
||||
PL_DHashTableFinish(tmp->mSubDocuments);
|
||||
delete tmp->mSubDocuments;
|
||||
tmp->mSubDocuments = nullptr;
|
||||
}
|
||||
|
||||
@ -2331,8 +2332,8 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
||||
// Delete references to sub-documents and kill the subdocument map,
|
||||
// if any. It holds strong references
|
||||
if (mSubDocuments) {
|
||||
PL_DHashTableDestroy(mSubDocuments);
|
||||
|
||||
PL_DHashTableFinish(mSubDocuments);
|
||||
delete mSubDocuments;
|
||||
mSubDocuments = nullptr;
|
||||
}
|
||||
|
||||
@ -3984,7 +3985,8 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc)
|
||||
SubDocInitEntry
|
||||
};
|
||||
|
||||
mSubDocuments = PL_NewDHashTable(&hash_table_ops, sizeof(SubDocMapEntry));
|
||||
mSubDocuments = new PLDHashTable();
|
||||
PL_DHashTableInit(mSubDocuments, &hash_table_ops, sizeof(SubDocMapEntry));
|
||||
}
|
||||
|
||||
// Add a mapping to the hash table
|
||||
|
@ -216,7 +216,8 @@ XULDocument::~XULDocument()
|
||||
|
||||
// Destroy our broadcaster map.
|
||||
if (mBroadcasterMap) {
|
||||
PL_DHashTableDestroy(mBroadcasterMap);
|
||||
PL_DHashTableFinish(mBroadcasterMap);
|
||||
delete mBroadcasterMap;
|
||||
}
|
||||
|
||||
delete mTemplateBuilderTable;
|
||||
@ -768,7 +769,8 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
|
||||
};
|
||||
|
||||
if (! mBroadcasterMap) {
|
||||
mBroadcasterMap = PL_NewDHashTable(&gOps, sizeof(BroadcasterMapEntry));
|
||||
mBroadcasterMap = new PLDHashTable();
|
||||
PL_DHashTableInit(mBroadcasterMap, &gOps, sizeof(BroadcasterMapEntry));
|
||||
}
|
||||
|
||||
BroadcasterMapEntry* entry =
|
||||
|
@ -174,12 +174,14 @@ Native2WrappedNativeMap::newMap(int length)
|
||||
|
||||
Native2WrappedNativeMap::Native2WrappedNativeMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
mTable = new PLDHashTable();
|
||||
PL_DHashTableInit(mTable, PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
}
|
||||
|
||||
Native2WrappedNativeMap::~Native2WrappedNativeMap()
|
||||
{
|
||||
PL_DHashTableDestroy(mTable);
|
||||
PL_DHashTableFinish(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -218,12 +220,14 @@ IID2WrappedJSClassMap::newMap(int length)
|
||||
|
||||
IID2WrappedJSClassMap::IID2WrappedJSClassMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = new PLDHashTable();
|
||||
PL_DHashTableInit(mTable, &Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
IID2WrappedJSClassMap::~IID2WrappedJSClassMap()
|
||||
{
|
||||
PL_DHashTableDestroy(mTable);
|
||||
PL_DHashTableFinish(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
|
||||
@ -247,12 +251,14 @@ IID2NativeInterfaceMap::newMap(int length)
|
||||
|
||||
IID2NativeInterfaceMap::IID2NativeInterfaceMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = new PLDHashTable();
|
||||
PL_DHashTableInit(mTable, &Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
IID2NativeInterfaceMap::~IID2NativeInterfaceMap()
|
||||
{
|
||||
PL_DHashTableDestroy(mTable);
|
||||
PL_DHashTableFinish(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -284,12 +290,14 @@ ClassInfo2NativeSetMap::newMap(int length)
|
||||
|
||||
ClassInfo2NativeSetMap::ClassInfo2NativeSetMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
mTable = new PLDHashTable();
|
||||
PL_DHashTableInit(mTable, PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
}
|
||||
|
||||
ClassInfo2NativeSetMap::~ClassInfo2NativeSetMap()
|
||||
{
|
||||
PL_DHashTableDestroy(mTable);
|
||||
PL_DHashTableFinish(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -314,12 +322,14 @@ ClassInfo2WrappedNativeProtoMap::newMap(int length)
|
||||
|
||||
ClassInfo2WrappedNativeProtoMap::ClassInfo2WrappedNativeProtoMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
mTable = new PLDHashTable();
|
||||
PL_DHashTableInit(mTable, PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
}
|
||||
|
||||
ClassInfo2WrappedNativeProtoMap::~ClassInfo2WrappedNativeProtoMap()
|
||||
{
|
||||
PL_DHashTableDestroy(mTable);
|
||||
PL_DHashTableFinish(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -430,12 +440,14 @@ NativeSetMap::newMap(int length)
|
||||
|
||||
NativeSetMap::NativeSetMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = new PLDHashTable();
|
||||
PL_DHashTableInit(mTable, &Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
NativeSetMap::~NativeSetMap()
|
||||
{
|
||||
PL_DHashTableDestroy(mTable);
|
||||
PL_DHashTableFinish(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -489,12 +501,14 @@ IID2ThisTranslatorMap::newMap(int length)
|
||||
|
||||
IID2ThisTranslatorMap::IID2ThisTranslatorMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = new PLDHashTable();
|
||||
PL_DHashTableInit(mTable, &Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
IID2ThisTranslatorMap::~IID2ThisTranslatorMap()
|
||||
{
|
||||
PL_DHashTableDestroy(mTable);
|
||||
PL_DHashTableFinish(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
@ -560,12 +574,14 @@ XPCNativeScriptableSharedMap::newMap(int length)
|
||||
|
||||
XPCNativeScriptableSharedMap::XPCNativeScriptableSharedMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = new PLDHashTable();
|
||||
PL_DHashTableInit(mTable, &Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
XPCNativeScriptableSharedMap::~XPCNativeScriptableSharedMap()
|
||||
{
|
||||
PL_DHashTableDestroy(mTable);
|
||||
PL_DHashTableFinish(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -606,13 +622,15 @@ XPCWrappedNativeProtoMap::newMap(int length)
|
||||
|
||||
XPCWrappedNativeProtoMap::XPCWrappedNativeProtoMap(int length)
|
||||
{
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(),
|
||||
sizeof(PLDHashEntryStub), length);
|
||||
mTable = new PLDHashTable();
|
||||
PL_DHashTableInit(mTable, PL_DHashGetStubOps(), sizeof(PLDHashEntryStub),
|
||||
length);
|
||||
}
|
||||
|
||||
XPCWrappedNativeProtoMap::~XPCWrappedNativeProtoMap()
|
||||
{
|
||||
PL_DHashTableDestroy(mTable);
|
||||
PL_DHashTableFinish(mTable);
|
||||
delete mTable;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -1421,7 +1421,8 @@ nsRuleNode::DestroyInternal(nsRuleNode ***aDestroyQueueTail)
|
||||
PL_DHashTableEnumerate(children, EnqueueRuleNodeChildren,
|
||||
&destroyQueueTail);
|
||||
*destroyQueueTail = nullptr; // ensure null-termination
|
||||
PL_DHashTableDestroy(children);
|
||||
PL_DHashTableFinish(children);
|
||||
delete children;
|
||||
} else if (HaveChildren()) {
|
||||
*destroyQueueTail = ChildrenList();
|
||||
do {
|
||||
@ -1604,9 +1605,9 @@ nsRuleNode::ConvertChildrenToHash(int32_t aNumKids)
|
||||
{
|
||||
NS_ASSERTION(!ChildrenAreHashed() && HaveChildren(),
|
||||
"must have a non-empty list of children");
|
||||
PLDHashTable *hash = PL_NewDHashTable(&ChildrenHashOps,
|
||||
sizeof(ChildrenHashEntry),
|
||||
aNumKids);
|
||||
PLDHashTable *hash = new PLDHashTable();
|
||||
PL_DHashTableInit(hash, &ChildrenHashOps, sizeof(ChildrenHashEntry),
|
||||
aNumKids);
|
||||
for (nsRuleNode* curr = ChildrenList(); curr; curr = curr->mNextSibling) {
|
||||
// This will never fail because of the initial size we gave the table.
|
||||
ChildrenHashEntry *entry = static_cast<ChildrenHashEntry*>(
|
||||
@ -9231,7 +9232,8 @@ nsRuleNode::SweepChildren(nsTArray<nsRuleNode*>& aSweepQueue)
|
||||
PL_DHashTableEnumerate(children, SweepHashEntry, &survivorsWithChildren);
|
||||
childrenDestroyed = oldChildCount - children->EntryCount();
|
||||
if (childrenDestroyed == oldChildCount) {
|
||||
PL_DHashTableDestroy(children);
|
||||
PL_DHashTableFinish(children);
|
||||
delete children;
|
||||
mChildren.asVoid = nullptr;
|
||||
}
|
||||
} else {
|
||||
|
@ -162,8 +162,9 @@ Assertion::Assertion(nsIRDFResource* aSource)
|
||||
|
||||
NS_ADDREF(mSource);
|
||||
|
||||
u.hash.mPropertyHash =
|
||||
PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry));
|
||||
u.hash.mPropertyHash = new PLDHashTable();
|
||||
PL_DHashTableInit(u.hash.mPropertyHash, PL_DHashGetStubOps(),
|
||||
sizeof(Entry));
|
||||
}
|
||||
|
||||
Assertion::Assertion(nsIRDFResource* aSource,
|
||||
@ -194,7 +195,8 @@ Assertion::~Assertion()
|
||||
if (mHashEntry && u.hash.mPropertyHash) {
|
||||
PL_DHashTableEnumerate(u.hash.mPropertyHash, DeletePropertyHashEntry,
|
||||
nullptr);
|
||||
PL_DHashTableDestroy(u.hash.mPropertyHash);
|
||||
PL_DHashTableFinish(u.hash.mPropertyHash);
|
||||
delete u.hash.mPropertyHash;
|
||||
u.hash.mPropertyHash = nullptr;
|
||||
}
|
||||
|
||||
|
@ -167,22 +167,6 @@ SizeOfEntryStore(uint32_t aCapacity, uint32_t aEntrySize, uint32_t* aNbytes)
|
||||
return uint64_t(*aNbytes) == nbytes64; // returns false on overflow
|
||||
}
|
||||
|
||||
PLDHashTable*
|
||||
PL_NewDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength)
|
||||
{
|
||||
PLDHashTable* table = new PLDHashTable();
|
||||
PL_DHashTableInit(table, aOps, aEntrySize, aLength);
|
||||
return table;
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableDestroy(PLDHashTable* aTable)
|
||||
{
|
||||
PL_DHashTableFinish(aTable);
|
||||
delete aTable;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute max and min load numbers (entry counts). We have a secondary max
|
||||
* that allows us to overload a table reasonably if it cannot be grown further
|
||||
|
@ -432,21 +432,6 @@ void PL_DHashFreeStringKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
|
||||
*/
|
||||
const PLDHashTableOps* PL_DHashGetStubOps(void);
|
||||
|
||||
/*
|
||||
* Dynamically allocate a new PLDHashTable, initialize it using
|
||||
* PL_DHashTableInit, and return its address. Never returns null.
|
||||
*/
|
||||
PLDHashTable* PL_NewDHashTable(
|
||||
const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
/*
|
||||
* Free |aTable|'s entry storage and |aTable| itself (both via
|
||||
* aTable->mOps->freeTable). Use this function to destroy a PLDHashTable that
|
||||
* was allocated on the heap via PL_NewDHashTable().
|
||||
*/
|
||||
void PL_DHashTableDestroy(PLDHashTable* aTable);
|
||||
|
||||
/*
|
||||
* Initialize aTable with aOps and aEntrySize. The table's initial capacity
|
||||
* will be chosen such that |aLength| elements can be inserted without
|
||||
@ -462,9 +447,8 @@ void PL_DHashTableInit(
|
||||
uint32_t aEntrySize, uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
/*
|
||||
* Free |aTable|'s entry storage (via aTable->mOps->freeTable). Use this
|
||||
* function to destroy a PLDHashTable that is allocated on the stack or in
|
||||
* static memory and was created via PL_DHashTableInit().
|
||||
* Clear |aTable|'s elements (via aTable->mOps->clearEntry) and free its entry
|
||||
* storage, if has any.
|
||||
*/
|
||||
void PL_DHashTableFinish(PLDHashTable* aTable);
|
||||
|
||||
|
@ -133,18 +133,13 @@ static bool test_pldhash_grow_to_max_capacity()
|
||||
nullptr
|
||||
};
|
||||
|
||||
// This is infallible.
|
||||
PLDHashTable* t = PL_NewDHashTable(&ops, sizeof(PLDHashEntryStub), 128);
|
||||
|
||||
// Check that New() sets |t->ops|.
|
||||
if (!t->IsInitialized()) {
|
||||
return false;
|
||||
}
|
||||
PLDHashTable t;
|
||||
PL_DHashTableInit(&t, &ops, sizeof(PLDHashEntryStub), 128);
|
||||
|
||||
// Keep inserting elements until failure occurs because the table is full.
|
||||
size_t numInserted = 0;
|
||||
while (true) {
|
||||
if (!PL_DHashTableAdd(t, (const void*)numInserted)) {
|
||||
if (!PL_DHashTableAdd(&t, (const void*)numInserted)) {
|
||||
break;
|
||||
}
|
||||
numInserted++;
|
||||
@ -156,7 +151,7 @@ static bool test_pldhash_grow_to_max_capacity()
|
||||
return false;
|
||||
}
|
||||
|
||||
PL_DHashTableDestroy(t);
|
||||
PL_DHashTableFinish(&t);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user