Bug 1187114 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in dom/xul/ with iterators. r=mccr8.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 22 Nov 2015 14:39:00 -0800
changeset 273662 eb825393c4efa5a4972abb685bfe070e67dad228
parent 273661 0f31b5fa382bf35fdebc49dd59f28941f7886015
child 273663 87c224b7103335b7d00a12cbaf5608ca34e4a461
push id68351
push usernnethercote@mozilla.com
push dateMon, 23 Nov 2015 03:20:06 +0000
treeherdermozilla-inbound@eb825393c4ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1187114
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1187114 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in dom/xul/ with iterators. r=mccr8.
dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp
--- a/dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp
+++ b/dom/xul/templates/nsXULTemplateQueryProcessorRDF.cpp
@@ -46,67 +46,42 @@ nsIRDFResource*           nsXULTemplateQ
 nsIRDFResource*           nsXULTemplateQueryProcessorRDF::kRDF_type;
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTemplateQueryProcessorRDF)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULTemplateQueryProcessorRDF)
     tmp->Done();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-static PLDHashOperator
-BindingDependenciesTraverser(nsISupports* key,
-                             nsXULTemplateQueryProcessorRDF::ResultArray* array,
-                             void* userArg)
-{
-    nsCycleCollectionTraversalCallback *cb = 
-        static_cast<nsCycleCollectionTraversalCallback*>(userArg);
-
-    int32_t i, count = array->Length();
-    for (i = 0; i < count; ++i) {
-        cb->NoteXPCOMChild(array->ElementAt(i));
-    }
-
-    return PL_DHASH_NEXT;
-}
-
-static PLDHashOperator
-MemoryElementTraverser(const uint32_t& key,
-                       nsCOMArray<nsXULTemplateResultRDF>* array,
-                       void* userArg)
-{
-    nsCycleCollectionTraversalCallback *cb = 
-        static_cast<nsCycleCollectionTraversalCallback*>(userArg);
-
-    int32_t i, count = array->Count();
-    for (i = 0; i < count; ++i) {
-        cb->NoteXPCOMChild(array->ObjectAt(i));
-    }
-
-    return PL_DHASH_NEXT;
-}
-
-static PLDHashOperator
-RuleToBindingTraverser(nsISupports* key, RDFBindingSet* binding, void* userArg)
-{
-    nsCycleCollectionTraversalCallback *cb = 
-        static_cast<nsCycleCollectionTraversalCallback*>(userArg);
-
-    cb->NoteXPCOMChild(key);
-
-    return PL_DHASH_NEXT;
-}
-
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULTemplateQueryProcessorRDF)
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDB)
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLastRef)
-    tmp->mBindingDependencies.EnumerateRead(BindingDependenciesTraverser,
-                                            &cb);
-    tmp->mMemoryElementToResultMap.EnumerateRead(MemoryElementTraverser,
-                                                 &cb);
-    tmp->mRuleToBindingsMap.EnumerateRead(RuleToBindingTraverser, &cb);
+
+    for (auto it = tmp->mBindingDependencies.Iter(); !it.Done(); it.Next()) {
+        nsXULTemplateQueryProcessorRDF::ResultArray* array = it.UserData();
+        int32_t count = array->Length();
+        for (int32_t i = 0; i < count; ++i) {
+            cb.NoteXPCOMChild(array->ElementAt(i));
+        }
+    }
+
+    for (auto it = tmp->mMemoryElementToResultMap.Iter();
+         !it.Done();
+         it.Next()) {
+        nsCOMArray<nsXULTemplateResultRDF>* array = it.UserData();
+        int32_t count = array->Count();
+        for (int32_t i = 0; i < count; ++i) {
+            cb.NoteXPCOMChild(array->ObjectAt(i));
+        }
+    }
+
+    for (auto it = tmp->mRuleToBindingsMap.Iter(); !it.Done(); it.Next()) {
+        cb.NoteXPCOMChild(it.Key());
+    }
+
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQueries)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsXULTemplateQueryProcessorRDF)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsXULTemplateQueryProcessorRDF)
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsXULTemplateQueryProcessorRDF)
     NS_INTERFACE_MAP_ENTRY(nsIXULTemplateQueryProcessor)
     NS_INTERFACE_MAP_ENTRY(nsIRDFObserver)