Bug 1187784 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in layout/ with iterators. r=heycam.
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 20 Oct 2015 22:18:20 -0700
changeset 304602 079e5922519897e7d275558c454ef3b9df8f945c
parent 304601 c86fcfbfc1c503b617279efac7d5a48328bdaa8b
child 304603 890488d5686905985a5c4336baaa171e129cabe3
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1187784
milestone44.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 1187784 (part 3) - Replace nsBaseHashtable::EnumerateRead() calls in layout/ with iterators. r=heycam.
layout/style/CounterStyleManager.cpp
--- a/layout/style/CounterStyleManager.cpp
+++ b/layout/style/CounterStyleManager.cpp
@@ -1982,35 +1982,27 @@ CounterStyleManager::~CounterStyleManage
 /* static */ void
 CounterStyleManager::InitializeBuiltinCounterStyles()
 {
   for (uint32_t i = 0; i < NS_STYLE_LIST_STYLE__MAX; ++i) {
     gBuiltinStyleTable[i].mStyle = i;
   }
 }
 
-#ifdef DEBUG
-static PLDHashOperator
-CheckRefCount(const nsSubstring& aKey,
-              CounterStyle* aStyle,
-              void* aArg)
-{
-  aStyle->AddRef();
-  auto refcnt = aStyle->Release();
-  NS_ASSERTION(!aStyle->IsDependentStyle() || refcnt == 1,
-               "Counter style is still referenced by other objects.");
-  return PL_DHASH_NEXT;
-}
-#endif
-
 void
 CounterStyleManager::Disconnect()
 {
 #ifdef DEBUG
-  mCacheTable.EnumerateRead(CheckRefCount, nullptr);
+  for (auto iter = mCacheTable.Iter(); !iter.Done(); iter.Next()) {
+    CounterStyle* style = iter.UserData();
+    style->AddRef();
+    auto refcnt = style->Release();
+    NS_ASSERTION(!style->IsDependentStyle() || refcnt == 1,
+                 "Counter style is still referenced by other objects.");
+  }
 #endif
   mCacheTable.Clear();
   mPresContext = nullptr;
 }
 
 CounterStyle*
 CounterStyleManager::BuildCounterStyle(const nsSubstring& aName)
 {
@@ -2094,50 +2086,44 @@ InvalidateOldStyle(const nsSubstring& aK
       }
     }
   }
   data->mChanged = data->mChanged || toBeUpdated || toBeRemoved;
   if (toBeRemoved) {
     if (aStyle->IsDependentStyle()) {
       if (aStyle->IsCustomStyle()) {
         // Since |aStyle| is being removed from mCacheTable, it won't be visited
-        // by our post-removal InvalidateDependentData() traversal. So, we have
-        // to give it a manual ResetDependentData() call. (This only really
-        // matters if something else is holding a reference & keeping it alive.)
+        // by our post-removal iteration. So, we have to give it a manual
+        // ResetDependentData() call. (This only really matters if something
+        // else is holding a reference and keeping it alive.)
         static_cast<CustomCounterStyle*>(aStyle.get())->ResetDependentData();
       }
       // The object has to be held here so that it will not be released
       // before all pointers that refer to it are reset. It will be
       // released when the MarkAndCleanData goes out of scope at the end
       // of NotifyRuleChanged().
       data->mToBeRemoved.AppendElement(aStyle);
     }
     return PL_DHASH_REMOVE;
   }
   return PL_DHASH_NEXT;
 }
 
-static PLDHashOperator
-InvalidateDependentData(const nsSubstring& aKey,
-                        CounterStyle* aStyle,
-                        void* aArg)
-{
-  if (aStyle->IsCustomStyle()) {
-    CustomCounterStyle* custom = static_cast<CustomCounterStyle*>(aStyle);
-    custom->ResetDependentData();
-  }
-  // There is no dependent data cached in DependentBuiltinCounterStyle
-  // instances, so we don't need to reset their data.
-  return PL_DHASH_NEXT;
-}
-
 bool
 CounterStyleManager::NotifyRuleChanged()
 {
   InvalidateOldStyleData data(mPresContext);
   mCacheTable.Enumerate(InvalidateOldStyle, &data);
   if (data.mChanged) {
-    mCacheTable.EnumerateRead(InvalidateDependentData, nullptr);
+    for (auto iter = mCacheTable.Iter(); !iter.Done(); iter.Next()) {
+      CounterStyle* style = iter.UserData();
+      if (style->IsCustomStyle()) {
+        CustomCounterStyle* custom = static_cast<CustomCounterStyle*>(style);
+        custom->ResetDependentData();
+      }
+      // There is no dependent data cached in DependentBuiltinCounterStyle
+      // instances, so we don't need to reset their data.
+    }
   }
   return data.mChanged;
 }
 
 } // namespace mozilla