Bug 609075 - speed up JSString::flatten a bit, part 1 (r=gal)
authorLuke Wagner <lw@mozilla.com>
Mon, 08 Nov 2010 14:35:29 -0800
changeset 57736 0ba07bd00178e01fea5d381e4dd7c1eb0be1bc04
parent 57735 95c792930e9302b794eb946a813fd9f2c4da8c5b
child 57737 30cabba0038843063f057da722b032b1f9207df3
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersgal
bugs609075
milestone2.0b8pre
Bug 609075 - speed up JSString::flatten a bit, part 1 (r=gal)
js/src/jsstr.cpp
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -207,17 +207,17 @@ RopeAllocSize(const size_t length, size_
     /*
      * Grow by 12.5% if the buffer is very large. Otherwise, round up to the
      * next power of 2. This is similar to what we do with arrays; see
      * JSObject::ensureDenseArrayElements.
      */
     if (length > ROPE_DOUBLING_MAX)
         size = minCap + (minCap / 8);
     else
-        size = 1 << (JS_CeilingLog2(minCap));
+        size = RoundUpPow2(minCap);
     *capacity = (size / sizeof(jschar)) - 1;
     JS_ASSERT(size >= sizeof(JSRopeBufferInfo));
     return size;
 }
 
 static JS_ALWAYS_INLINE JSRopeBufferInfo *
 ObtainRopeBuffer(JSContext *cx, bool usingLeft, bool usingRight,
                  JSRopeBufferInfo *sourceBuffer, size_t length,