Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in js/ r?bbouvier
MozReview-Commit-ID: 9QrvFfu3wbL
--- a/js/src/ctypes/CTypes.cpp
+++ b/js/src/ctypes/CTypes.cpp
@@ -4566,18 +4566,18 @@ CType::Trace(JSTracer* trc, JSObject* ob
return;
FunctionInfo* fninfo = static_cast<FunctionInfo*>(slot.toPrivate());
MOZ_ASSERT(fninfo);
// Identify our objects to the tracer.
JS::TraceEdge(trc, &fninfo->mABI, "abi");
JS::TraceEdge(trc, &fninfo->mReturnType, "returnType");
- for (size_t i = 0; i < fninfo->mArgTypes.length(); ++i)
- JS::TraceEdge(trc, &fninfo->mArgTypes[i], "argType");
+ for (auto & argType : fninfo->mArgTypes)
+ JS::TraceEdge(trc, &argType, "argType");
break;
}
default:
// Nothing to do here.
break;
}
}
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -933,18 +933,17 @@ template <typename ParseHandler>
bool
Parser<ParseHandler>::hasValidSimpleStrictParameterNames()
{
MOZ_ASSERT(pc->isFunctionBox() && pc->functionBox()->hasSimpleParameterList());
if (pc->functionBox()->hasDuplicateParameters)
return false;
- for (size_t i = 0; i < pc->positionalFormalParameterNames().length(); i++) {
- JSAtom* name = pc->positionalFormalParameterNames()[i];
+ for (auto* name : pc->positionalFormalParameterNames()) {
MOZ_ASSERT(name);
if (!isValidStrictBinding(name->asPropertyName()))
return false;
}
return true;
}
template <typename ParseHandler>
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -2887,18 +2887,17 @@ SliceSparse(JSContext* cx, HandleObject
bool success;
if (!GetIndexedPropertiesInRange(cx, obj, begin, end, indexes, &success))
return false;
if (!success)
return SliceSlowly(cx, obj, begin, end, result);
RootedValue value(cx);
- for (size_t i = 0, len = indexes.length(); i < len; i++) {
- uint32_t index = indexes[i];
+ for (size_t index : indexes) {
MOZ_ASSERT(begin <= index && index < end);
bool hole;
if (!GetElement(cx, obj, index, &hole, &value))
return false;
if (!hole && !DefineElement(cx, result, index - begin, value))
return false;