From 015cb7815dbdbb93a2011250b32deb6bcd74e044 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 8 Jun 2015 16:01:23 -0700 Subject: [PATCH] Bug 1171833 - Remove PL_DHashTableEnumerator use from nsPropertyTable. r=smaug. --- dom/base/nsPropertyTable.cpp | 50 ++++++++++-------------------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/dom/base/nsPropertyTable.cpp b/dom/base/nsPropertyTable.cpp index 0b34167d9af..a0524d191eb 100644 --- a/dom/base/nsPropertyTable.cpp +++ b/dom/base/nsPropertyTable.cpp @@ -133,30 +133,16 @@ nsPropertyTable::Enumerate(nsPropertyOwner aObject, } } -struct PropertyEnumeratorData -{ - nsIAtom* mName; - NSPropertyFunc mCallBack; - void* mData; -}; - -static PLDHashOperator -PropertyEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, - uint32_t aNumber, void* aArg) -{ - PropertyListMapEntry* entry = static_cast(aHdr); - PropertyEnumeratorData* data = static_cast(aArg); - data->mCallBack(const_cast(entry->key), data->mName, entry->value, - data->mData); - return PL_DHASH_NEXT; -} - void nsPropertyTable::EnumerateAll(NSPropertyFunc aCallBack, void* aData) { for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) { - PropertyEnumeratorData data = { prop->mName, aCallBack, aData }; - PL_DHashTableEnumerate(&prop->mObjectValueMap, PropertyEnumerator, &data); + PLDHashTable::Iterator iter(&prop->mObjectValueMap); + while (iter.HasMoreEntries()) { + auto entry = static_cast(iter.NextEntry()); + aCallBack(const_cast(entry->key), prop->mName, entry->value, + aData); + } } } @@ -294,25 +280,17 @@ nsPropertyTable::PropertyList::~PropertyList() { } -static PLDHashOperator -DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr, - uint32_t number, void *arg) -{ - nsPropertyTable::PropertyList *propList = - static_cast(arg); - PropertyListMapEntry* entry = static_cast(hdr); - - propList->mDtorFunc(const_cast(entry->key), propList->mName, - entry->value, propList->mDtorData); - return PL_DHASH_NEXT; -} - void nsPropertyTable::PropertyList::Destroy() { - // Enumerate any remaining object/value pairs and destroy the value object - if (mDtorFunc) - PL_DHashTableEnumerate(&mObjectValueMap, DestroyPropertyEnumerator, this); + // Enumerate any remaining object/value pairs and destroy the value object. + if (mDtorFunc) { + PLDHashTable::Iterator iter(&mObjectValueMap); + while (iter.HasMoreEntries()) { + auto entry = static_cast(iter.NextEntry()); + mDtorFunc(const_cast(entry->key), mName, entry->value, mDtorData); + } + } } bool