Bug 737384 - Use reserve rather than resize for iterator wrapping (r=luke, a=akeybl)
authorBill McCloskey <wmccloskey@mozilla.com>
Fri, 13 Apr 2012 14:10:50 -0700
changeset 92091 e158b91dd28a36ae101c2426fc059581eed94cd4
parent 92090 7dfac7263e726f22c4d0d0e9d72e9859cfcd938f
child 92092 3bd6203cc61bdbaddf26e2a54a9f4e671aeb4bb8
push idunknown
push userunknown
push dateunknown
reviewersluke, akeybl
bugs737384
milestone13.0a2
Bug 737384 - Use reserve rather than resize for iterator wrapping (r=luke, a=akeybl)
js/src/jswrapper.cpp
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -682,24 +682,24 @@ Reify(JSContext *cx, JSCompartment *orig
      * Wrap the elements in the iterator's snapshot.
      * N.B. the order of closing/creating iterators is important due to the
      * implicit cx->enumerators state.
      */
     size_t length = ni->numKeys();
     bool isKeyIter = ni->isKeyIter();
     AutoIdVector keys(cx);
     if (length > 0) {
-        if (!keys.resize(length))
+        if (!keys.reserve(length))
             return false;
         for (size_t i = 0; i < length; ++i) {
             jsid id;
             if (!ValueToId(cx, StringValue(ni->begin()[i]), &id))
                 return false;
             id = js_CheckForStringIndex(id);
-            keys[i] = id;
+            keys.infallibleAppend(id);
             if (!origin->wrapId(cx, &keys[i]))
                 return false;
         }
     }
 
     close.clear();
     if (!CloseIterator(cx, iterObj))
         return false;