Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in js/ r?bbouvier draft
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 08 Feb 2017 14:24:51 +0100
changeset 482827 1b8462da1f392652858fbb433205ad985ee9e3dd
parent 482826 06622daa9e79347ad98822c129e4cd28c750d207
child 482828 487d56cff1b25deab7d134ad289841f1bc744d37
push id45175
push userbmo:sledru@mozilla.com
push dateMon, 13 Feb 2017 14:41:08 +0000
reviewersbbouvier
bugs1337358
milestone54.0a1
Bug 1337358 - Converts for(...; ...; ...) loops to use the new range-based loops in C++11 in js/ r?bbouvier MozReview-Commit-ID: 9QrvFfu3wbL
js/src/ctypes/CTypes.cpp
js/src/frontend/Parser.cpp
js/src/jsarray.cpp
--- 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;