Bug 1094552 (part 2) - DMD: tweak Range and Enum use. r=mccr8.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 23 Nov 2014 17:39:17 -0800
changeset 217036 7a74315e55f511d81e00b4cf85fb8b47a80749a3
parent 217035 303e4680ae2b493856c8b57a685b8c894181d213
child 217037 c3ecdd9ea544eb0407fbeda412acfb6793e7c9a2
push id52212
push usernnethercote@mozilla.com
push dateMon, 24 Nov 2014 04:23:22 +0000
treeherdermozilla-inbound@c3ecdd9ea544 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1094552
milestone36.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 1094552 (part 2) - DMD: tweak Range and Enum use. r=mccr8. This patch: - Uses |auto| in Range loops, so more of them fit on a single line. - Converts one use of HashSet::Enum (which is only needed if you're modifying the HashSet as you iterate) to HashSet::Range.
memory/replace/dmd/DMD.cpp
--- a/memory/replace/dmd/DMD.cpp
+++ b/memory/replace/dmd/DMD.cpp
@@ -538,19 +538,17 @@ public:
     return newString;
   }
 
   size_t
   SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
   {
     size_t n = 0;
     n += mSet.sizeOfExcludingThis(aMallocSizeOf);
-    for (StringHashSet::Range r = mSet.all();
-         !r.empty();
-         r.popFront()) {
+    for (auto r = mSet.all(); !r.empty(); r.popFront()) {
       n += aMallocSizeOf(r.front());
     }
     return n;
   }
 
 private:
   struct StringHasher
   {
@@ -931,19 +929,18 @@ static void
 GatherUsedStackTraces(StackTraceSet& aStackTraces)
 {
   MOZ_ASSERT(gStateLock->IsLocked());
   MOZ_ASSERT(Thread::Fetch()->InterceptsAreBlocked());
 
   aStackTraces.finish();
   aStackTraces.init(512);
 
-  for (BlockTable::Range r = gBlockTable->all(); !r.empty(); r.popFront()) {
-    const Block& b = r.front();
-    b.AddStackTracesToTable(aStackTraces);
+  for (auto r = gBlockTable->all(); !r.empty(); r.popFront()) {
+    r.front().AddStackTracesToTable(aStackTraces);
   }
 }
 
 // Delete stack traces that we aren't using, and compact our hashtable.
 static void
 GCStackTraces()
 {
   MOZ_ASSERT(gStateLock->IsLocked());
@@ -1434,19 +1431,17 @@ SizeOfInternal(Sizes* aSizes)
   MOZ_ASSERT(gStateLock->IsLocked());
   MOZ_ASSERT(Thread::Fetch()->InterceptsAreBlocked());
 
   aSizes->Clear();
 
   StackTraceSet usedStackTraces;
   GatherUsedStackTraces(usedStackTraces);
 
-  for (StackTraceTable::Range r = gStackTraceTable->all();
-       !r.empty();
-       r.popFront()) {
+  for (auto r = gStackTraceTable->all(); !r.empty(); r.popFront()) {
     StackTrace* const& st = r.front();
 
     if (usedStackTraces.has(st)) {
       aSizes->mStackTracesUsed += MallocSizeOf(st);
     } else {
       aSizes->mStackTracesUnused += MallocSizeOf(st);
     }
   }
@@ -1470,17 +1465,17 @@ DMDFuncs::SizeOf(Sizes* aSizes)
 void
 DMDFuncs::ClearReports()
 {
   AutoLockState lock;
 
   // Unreport all blocks that were marked reported by a memory reporter.  This
   // excludes those that were reported on allocation, because they need to keep
   // their reported marking.
-  for (BlockTable::Range r = gBlockTable->all(); !r.empty(); r.popFront()) {
+  for (auto r = gBlockTable->all(); !r.empty(); r.popFront()) {
     r.front().UnreportIfNotReportedOnAlloc();
   }
 }
 
 class ToIdStringConverter MOZ_FINAL
 {
 public:
   ToIdStringConverter() : mNextId(0) { mIdMap.init(512); }
@@ -1579,17 +1574,17 @@ AnalyzeReportsImpl(UniquePtr<JSONWriteFu
     writer.EndObject();
 
     StatusMsg("  Constructing the heap block list...\n");
 
     ToIdStringConverter isc;
 
     writer.StartArrayProperty("blockList");
     {
-      for (BlockTable::Range r = gBlockTable->all(); !r.empty(); r.popFront()) {
+      for (auto r = gBlockTable->all(); !r.empty(); r.popFront()) {
         const Block& b = r.front();
         b.AddStackTracesToTable(usedStackTraces);
 
         writer.StartObjectElement(writer.SingleLineStyle);
         {
           if (!b.IsSampled()) {
             writer.IntProperty("req", b.ReqSize());
             if (b.SlopSize() > 0) {
@@ -1614,18 +1609,18 @@ AnalyzeReportsImpl(UniquePtr<JSONWriteFu
       }
     }
     writer.EndArray();
 
     StatusMsg("  Constructing the stack trace table...\n");
 
     writer.StartObjectProperty("traceTable");
     {
-      for (StackTraceSet::Enum e(usedStackTraces); !e.empty(); e.popFront()) {
-        const StackTrace* const st = e.front();
+      for (auto r = usedStackTraces.all(); !r.empty(); r.popFront()) {
+        const StackTrace* const st = r.front();
         writer.StartArrayProperty(isc.ToIdString(st), writer.SingleLineStyle);
         {
           for (uint32_t i = 0; i < st->Length(); i++) {
             const void* pc = st->Pc(i);
             writer.StringElement(isc.ToIdString(pc));
             usedPcs.put(pc);
           }
         }