Bug 1173247 (part 2) - Remove PL_DHashTableEnumerate() uses from nsDiskCacheBindery. r=michal.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 10 Jun 2015 13:07:41 -0700
changeset 279344 416257a77854f00da2c5938c724f2bbf6f3f6476
parent 279343 2797813b89bc013796edb12216d3c27952b66696
child 279345 306758f7b34056584782d7c77d69bc59a8436bdb
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmichal
bugs1173247
milestone41.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 1173247 (part 2) - Remove PL_DHashTableEnumerate() uses from nsDiskCacheBindery. r=michal.
netwerk/cache/nsDiskCacheBinding.cpp
--- a/netwerk/cache/nsDiskCacheBinding.cpp
+++ b/netwerk/cache/nsDiskCacheBinding.cpp
@@ -314,57 +314,39 @@ nsDiskCacheBindery::RemoveBinding(nsDisk
         } else {
             // promote next binding to head, and unlink this binding
             hashEntry->mBinding = (nsDiskCacheBinding *)PR_NEXT_LINK(binding);
         }
     }
     PR_REMOVE_AND_INIT_LINK(binding);
 }
 
-
 /**
- *  ActiveBinding : PLDHashTable enumerate function to verify active bindings
- */
-
-PLDHashOperator
-ActiveBinding(PLDHashTable *    table,
-              PLDHashEntryHdr * hdr,
-              uint32_t          number,
-              void *            arg)
-{
-    nsDiskCacheBinding * binding = ((HashTableEntry *)hdr)->mBinding;
-    NS_ASSERTION(binding, "### disk cache binding = nullptr!");
-    
-    nsDiskCacheBinding * head = binding;
-    do {   
-        if (binding->IsActive()) {
-           *((bool *)arg) = true;
-            return PL_DHASH_STOP;
-        }
-
-        binding = (nsDiskCacheBinding *)PR_NEXT_LINK(binding);
-    } while (binding != head);
-
-    return PL_DHASH_NEXT;
-}
-
-
-/**
- *  ActiveBindings : return true if any bindings have open descriptors
+ * ActiveBindings: return true if any bindings have open descriptors.
  */
 bool
 nsDiskCacheBindery::ActiveBindings()
 {
     NS_ASSERTION(initialized, "nsDiskCacheBindery not initialized");
     if (!initialized) return false;
 
-    bool    activeBinding = false;
-    PL_DHashTableEnumerate(&table, ActiveBinding, &activeBinding);
+    PLDHashTable::Iterator iter(&table);
+    while (iter.HasMoreEntries()) {
+        auto entry = static_cast<HashTableEntry*>(iter.NextEntry());
+        nsDiskCacheBinding* binding = entry->mBinding;
+        nsDiskCacheBinding* head = binding;
+        do {
+            if (binding->IsActive()) {
+                return true;
+            }
+            binding = (nsDiskCacheBinding *)PR_NEXT_LINK(binding);
+        } while (binding != head);
+    }
 
-    return activeBinding;
+    return false;
 }
 
 /**
  * SizeOfExcludingThis: return the amount of heap memory (bytes) being used by
  * the bindery.
  */
 size_t
 nsDiskCacheBindery::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf)