Bug 1039551 - NewString/NewStringDontDeflate should create inline strings if possible. r=njn
☠☠ backed out by a41861d55096 ☠ ☠
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 18 Jul 2014 17:07:34 +0200
changeset 216858 a4db87a48b24aa254deb527b1811b347b32a950c
parent 216857 fad52f3c9132bc0f16ded3783c454d047cf379bf
child 216859 be9e86108cf95b31f73c1fc1cf7b8370f1b173c3
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1039551
milestone33.0a1
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 1039551 - NewString/NewStringDontDeflate should create inline strings if possible. r=njn
js/src/jsstr.cpp
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -4397,16 +4397,26 @@ js::NewStringDontDeflate(ThreadSafeConte
         if (StaticStrings::hasUnit(c)) {
             // Free |chars| because we're taking possession of it, but it's no
             // longer needed because we use the static string instead.
             js_free(chars);
             return cx->staticStrings().getUnit(c);
         }
     }
 
+    if (JSFatInlineString::lengthFits<CharT>(length)) {
+        JSInlineString *str =
+            NewFatInlineString<allowGC>(cx, mozilla::Range<const CharT>(chars, length));
+        if (!str)
+            return nullptr;
+
+        js_free(chars);
+        return str;
+    }
+
     return JSFlatString::new_<allowGC>(cx, chars, length);
 }
 
 template JSFlatString *
 js::NewStringDontDeflate<CanGC>(ThreadSafeContext *cx, jschar *chars, size_t length);
 
 template JSFlatString *
 js::NewStringDontDeflate<NoGC>(ThreadSafeContext *cx, jschar *chars, size_t length);