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 id17032
push userrsayre@mozilla.com
push dateWed, 17 Nov 2010 21:55:39 +0000
treeherdermozilla-central@78a42f77bb90 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgal
bugs609075
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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,