Bug 1478879 - Remove Range/Enum use in devtools/. r=sfink
MozReview-Commit-ID: 3WoXwZnZe4w
--- 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.