Bug 1398226 - Remove the indirection through NewDependentString when creating inline-strings in StaticStrings::getUnitStringForElement. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Fri, 08 Sep 2017 19:13:36 +0200
changeset 429846 cdaed5454569de4a3bce86b2d6e2a7543f67a658
parent 429845 9a676cb6f09a4d0b29cc8b0072acc035c2082224
child 429847 781bc2a066f2d8fab47e1c8c897491c1c488fbed
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1398226
milestone57.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 1398226 - Remove the indirection through NewDependentString when creating inline-strings in StaticStrings::getUnitStringForElement. r=jandem
js/src/jsstr.cpp
js/src/vm/String-inl.h
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -517,19 +517,21 @@ static const JSFunctionSpec string_funct
 };
 
 static const unsigned STRING_ELEMENT_ATTRS = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT;
 
 static bool
 str_enumerate(JSContext* cx, HandleObject obj)
 {
     RootedString str(cx, obj->as<StringObject>().unbox());
+    js::StaticStrings& staticStrings = cx->staticStrings();
+
     RootedValue value(cx);
     for (size_t i = 0, length = str->length(); i < length; i++) {
-        JSString* str1 = NewDependentString(cx, str, i, 1);
+        JSString* str1 = staticStrings.getUnitStringForElement(cx, str, i);
         if (!str1)
             return false;
         value.setString(str1);
         if (!DefineDataElement(cx, obj, i, value, STRING_ELEMENT_ATTRS | JSPROP_RESOLVING))
             return false;
     }
 
     return true;
--- a/js/src/vm/String-inl.h
+++ b/js/src/vm/String-inl.h
@@ -343,17 +343,17 @@ js::StaticStrings::getUnitStringForEleme
 {
     MOZ_ASSERT(index < str->length());
 
     char16_t c;
     if (!str->getChar(cx, index, &c))
         return nullptr;
     if (c < UNIT_STATIC_LIMIT)
         return getUnit(c);
-    return NewDependentString(cx, str, index, 1);
+    return js::NewInlineString<CanGC>(cx, mozilla::Range<const char16_t>(&c, 1));
 }
 
 MOZ_ALWAYS_INLINE void
 JSString::finalize(js::FreeOp* fop)
 {
     /* FatInline strings are in a different arena. */
     MOZ_ASSERT(getAllocKind() != js::gc::AllocKind::FAT_INLINE_STRING);
     MOZ_ASSERT(getAllocKind() != js::gc::AllocKind::FAT_INLINE_ATOM);