Bug 1187139 (part 1) - Replace nsBaseHashtable::Enumerate() calls in accessible/ with iterators. r=tbsaunde.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 29 Nov 2015 14:02:07 -0800
changeset 308980 a7ba739d20a99e0808eed568175aa9404f2b4929
parent 308979 c91eff1c2734d0ac4a056e4938c767f6cb6cd8a4
child 308981 06f4c59269952cb31914815e3b69d038f0da3c8d
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1187139
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 1187139 (part 1) - Replace nsBaseHashtable::Enumerate() calls in accessible/ with iterators. r=tbsaunde.
accessible/base/nsAccCache.h
--- a/accessible/base/nsAccCache.h
+++ b/accessible/base/nsAccCache.h
@@ -7,45 +7,37 @@
 #define _nsAccCache_H_
 
 #include "xpcAccessibleDocument.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // Accessible cache utils
 ////////////////////////////////////////////////////////////////////////////////
 
-/**
- * Shutdown and removes the accessible from cache.
- */
-template <class T>
-static PLDHashOperator
-ClearCacheEntry(const void* aKey, RefPtr<T>& aAccessible, void* aUserArg)
-{
-  NS_ASSERTION(aAccessible, "Calling ClearCacheEntry with a nullptr pointer!");
-  if (aAccessible && !aAccessible->IsDefunct())
-    aAccessible->Shutdown();
-
-  return PL_DHASH_REMOVE;
-}
-
 template <class T>
 static PLDHashOperator
 UnbindCacheEntryFromDocument(const void* aKey, RefPtr<T>& aAccessible,
                              void* aUserArg)
 {
   MOZ_ASSERT(aAccessible && !aAccessible->IsDefunct());
   aAccessible->Document()->UnbindFromDocument(aAccessible);
 
   return PL_DHASH_REMOVE;
 }
 
 /**
  * Clear the cache and shutdown the accessibles.
  */
-
 template <class T>
 static void
 ClearCache(nsRefPtrHashtable<nsPtrHashKey<const void>, T>& aCache)
 {
-  aCache.Enumerate(ClearCacheEntry<T>, nullptr);
+  for (auto iter = aCache.Iter(); !iter.Done(); iter.Next()) {
+    T* accessible = iter.Data();
+    MOZ_ASSERT(accessible);
+    if (accessible && !accessible->IsDefunct()) {
+      accessible->Shutdown();
+    }
+    iter.Remove();
+  }
 }
 
 #endif