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>
Tue, 07 Feb 2017 13:18:03 +0100
changeset 479858 2e22694945b721a18dd2fbb1d5db57b4b4fbe9c0
parent 479857 fdc56e589a4e3aaf33d8cf01a86f4aae09b4eeb9
child 479859 f54cdd43eb0d8ce39f07462d78ee062917acff7a
push id44391
push userbmo:sledru@mozilla.com
push dateTue, 07 Feb 2017 13:22:28 +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
@@ -4565,18 +4565,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 & mArgType : fninfo->mArgTypes)
+      JS::TraceEdge(trc, &mArgType, "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
@@ -2860,18 +2860,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 (unsigned int 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;