Bug 1478879 - Remove Range/Enum use in devtools/. r=sfink draft
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 31 Jul 2018 10:31:00 +1000
changeset 825239 8e4de81ff4b2f8ba38c80be362440b02fbec0c5a
parent 825238 ea13b88f0403184b6308d95c47e4dee40095f06f
child 825240 b124b8263c9abf43d953469cca02597feba8b316
push id118039
push usernnethercote@mozilla.com
push dateWed, 01 Aug 2018 03:07:33 +0000
reviewerssfink
bugs1478879
milestone63.0a1
Bug 1478879 - Remove Range/Enum use in devtools/. r=sfink MozReview-Commit-ID: 3WoXwZnZe4w
devtools/shared/heapsnapshot/HeapSnapshot.cpp
js/public/UbiNodeShortestPaths.h
--- a/devtools/shared/heapsnapshot/HeapSnapshot.cpp
+++ b/devtools/shared/heapsnapshot/HeapSnapshot.cpp
@@ -457,18 +457,18 @@ HeapSnapshot::init(JSContext* cx, const 
       return false;
     if (NS_WARN_IF(!saveNode(node, edgeReferents)))
       return false;
   }
 
   // Check the set of node ids referred to by edges we found and ensure that we
   // have the node corresponding to each id. If we don't have all of them, it is
   // unsafe to perform analyses of this heap snapshot.
-  for (auto range = edgeReferents.all(); !range.empty(); range.popFront()) {
-    if (NS_WARN_IF(!nodes.has(range.front())))
+  for (auto iter = edgeReferents.iter(); !iter.done(); iter.next()) {
+    if (NS_WARN_IF(!nodes.has(iter.get())))
       return false;
   }
 
   return true;
 }
 
 
 /*** Heap Snapshot Analyses ***********************************************************************/
@@ -648,21 +648,21 @@ HeapSnapshot::ComputeShortestPaths(JSCon
   // paths found.
 
   RootedObject resultsMap(cx, JS::NewMapObject(cx));
   if (NS_WARN_IF(!resultsMap)) {
     rv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
-  for (auto range = shortestPaths.eachTarget(); !range.empty(); range.popFront()) {
-    JS::RootedValue key(cx, JS::NumberValue(range.front().identifier()));
+  for (auto iter = shortestPaths.targetIter(); !iter.done(); iter.next()) {
+    JS::RootedValue key(cx, JS::NumberValue(iter.get().identifier()));
     JS::AutoValueVector paths(cx);
 
-    bool ok = shortestPaths.forEachPath(range.front(), [&](JS::ubi::Path& path) {
+    bool ok = shortestPaths.forEachPath(iter.get(), [&](JS::ubi::Path& path) {
       JS::AutoValueVector pathValues(cx);
 
       for (JS::ubi::BackEdge* edge : path) {
         JS::RootedObject pathPart(cx, JS_NewPlainObject(cx));
         if (!pathPart) {
           return false;
         }
 
--- a/js/public/UbiNodeShortestPaths.h
+++ b/js/public/UbiNodeShortestPaths.h
@@ -265,23 +265,23 @@ struct JS_PUBLIC_API(ShortestPaths)
         // use-after-free.
         paths.backEdges_ = std::move(traversal.visited);
 
         MOZ_ASSERT(paths.initialized());
         return mozilla::Some(std::move(paths));
     }
 
     /**
-     * Get a range that iterates over each target node we searched for retaining
-     * paths for. The returned range must not outlive the `ShortestPaths`
+     * Get an iterator over each target node we searched for retaining paths
+     * for. The returned iterator must not outlive the `ShortestPaths`
      * instance.
      */
-    NodeSet::Range eachTarget() const {
+    NodeSet::Iterator targetIter() const {
         MOZ_ASSERT(initialized());
-        return targets_.all();
+        return targets_.iter();
     }
 
     /**
      * Invoke the provided functor/lambda/callable once for each retaining path
      * discovered for `target`. The `func` is passed a single `JS::ubi::Path&`
      * argument, which contains each edge along the path ordered starting from
      * the root and ending at the target, and must not outlive the scope of the
      * call.