Back out 56ec5e954858 (from bug 685783) due to a Dromaeo regression.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 20 Oct 2011 15:47:39 -0700
changeset 79680 6f0c66b2ce76d715f744b11137ad6f0e81e1f72a
parent 79679 7e3755411d0966649fc1a9d62d4226bdf78313eb
child 79681 107c99294be752ed674a6327fc49c0e96dffaa68
push idunknown
push userunknown
push dateunknown
bugs685783
milestone10.0a1
backs out56ec5e954858b976485d9f4de4a070708470c364
Back out 56ec5e954858 (from bug 685783) due to a Dromaeo regression.
js/public/Vector.h
--- a/js/public/Vector.h
+++ b/js/public/Vector.h
@@ -555,36 +555,29 @@ Vector<T,N,AP>::~Vector()
  */
 template <class T, size_t N, class AP>
 STATIC_POSTCONDITION(!return || newCap >= curLength + lengthInc)
 inline bool
 Vector<T,N,AP>::calculateNewCapacity(size_t curLength, size_t lengthInc,
                                      size_t &newCap)
 {
     size_t newMinCap = curLength + lengthInc;
-    size_t newMinSize = newMinCap * sizeof(T);
 
     /*
      * Check for overflow in the above addition, below CEILING_LOG2, and later
      * multiplication by sizeof(T).
      */
     if (newMinCap < curLength ||
         newMinCap & tl::MulOverflowMask<2 * sizeof(T)>::result) {
         this->reportAllocOverflow();
         return false;
     }
 
-    /*
-     * It's best to request 2^N sized chunks because they are unlikely to be
-     * rounded up by the allocator.  (Asking for a 2^N number of elements isn't
-     * as good, because if sizeof(T) is not a power-of-two that would result in
-     * a non-2^N request size, which can cause waste.)
-     */
-    size_t newSize = RoundUpPow2(newMinSize);
-    newCap = newSize / sizeof(T);
+    /* Round up to next power of 2. */
+    newCap = RoundUpPow2(newMinCap);
 
     /*
      * Do not allow a buffer large enough that the expression ((char *)end() -
      * (char *)begin()) overflows ptrdiff_t. See Bug 510319.
      */
     if (newCap & tl::UnsafeRangeSizeMask<T>::result) {
         this->reportAllocOverflow();
         return false;