diff --git a/dom/base/DirectionalityUtils.cpp b/dom/base/DirectionalityUtils.cpp index 753ddbaf31e7..09f4b199fdfa 100644 --- a/dom/base/DirectionalityUtils.cpp +++ b/dom/base/DirectionalityUtils.cpp @@ -490,15 +490,15 @@ private: return map; } - static PLDHashOperator SetNodeDirection(nsPtrHashKey* aEntry, void* aDir) + static nsCheapSetOperator SetNodeDirection(nsPtrHashKey* aEntry, void* aDir) { MOZ_ASSERT(aEntry->GetKey()->IsElement(), "Must be an Element"); aEntry->GetKey()->SetDirectionality(*reinterpret_cast(aDir), true); - return PL_DHASH_NEXT; + return OpNext; } - static PLDHashOperator ResetNodeDirection(nsPtrHashKey* aEntry, void* aData) + static nsCheapSetOperator ResetNodeDirection(nsPtrHashKey* aEntry, void* aData) { MOZ_ASSERT(aEntry->GetKey()->IsElement(), "Must be an Element"); // run the downward propagation algorithm @@ -516,15 +516,15 @@ private: rootNode->ClearHasDirAutoSet(); rootNode->UnsetProperty(nsGkAtoms::dirAutoSetBy); } - return PL_DHASH_REMOVE; + return OpRemove; } - static PLDHashOperator ClearEntry(nsPtrHashKey* aEntry, void* aData) + static nsCheapSetOperator ClearEntry(nsPtrHashKey* aEntry, void* aData) { Element* rootNode = aEntry->GetKey(); rootNode->ClearHasDirAutoSet(); rootNode->UnsetProperty(nsGkAtoms::dirAutoSetBy); - return PL_DHASH_REMOVE; + return OpRemove; } public: diff --git a/xpcom/ds/nsCheapSets.h b/xpcom/ds/nsCheapSets.h index 2ebcc012ab67..e61febffe5a6 100644 --- a/xpcom/ds/nsCheapSets.h +++ b/xpcom/ds/nsCheapSets.h @@ -10,6 +10,12 @@ #include "nsTHashtable.h" #include +enum nsCheapSetOperator +{ + OpNext = 0, // enumerator says continue + OpRemove = 1, // enumerator says remove and continue +}; + /** * A set that takes up minimal size when there are 0 or 1 entries in the set. * Use for cases where sizes of 0 and 1 are even slightly common. @@ -19,7 +25,7 @@ class nsCheapSet { public: typedef typename EntryType::KeyType KeyType; - typedef PLDHashOperator (*Enumerator)(EntryType* aEntry, void* userArg); + typedef nsCheapSetOperator (*Enumerator)(EntryType* aEntry, void* userArg); nsCheapSet() : mState(ZERO) {} ~nsCheapSet() { Clear(); } @@ -70,13 +76,21 @@ public: case ZERO: return 0; case ONE: - if (aEnumFunc(GetSingleEntry(), aUserArg) == PL_DHASH_REMOVE) { + if (aEnumFunc(GetSingleEntry(), aUserArg) == OpRemove) { GetSingleEntry()->~EntryType(); mState = ZERO; } return 1; - case MANY: - return mUnion.table->EnumerateEntries(aEnumFunc, aUserArg); + case MANY: { + uint32_t n = mUnion.table->Count(); + for (auto iter = mUnion.table->Iter(); !iter.Done(); iter.Next()) { + auto entry = static_cast(iter.Get()); + if (aEnumFunc(entry, aUserArg) == OpRemove) { + iter.Remove(); + } + } + return n; + } default: NS_NOTREACHED("bogus state"); return 0;