Bug 1436065 - Add JS_NewLatin1String API to create Latin1 strings without copying. r=luke
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 07 Feb 2018 14:38:00 +0100
changeset 402776 17704f81efef6b2b3b93fb0d80d6f128cf85faf0
parent 402775 1157f9e6cce081e0f05f0e62e5d16b816f726456
child 402777 f1a8cafe2ed9702e3e3709d8836bd8b12f93cf12
push id33402
push useraciure@mozilla.com
push dateWed, 07 Feb 2018 22:06:27 +0000
treeherdermozilla-central@8cc2427a322c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1436065
milestone60.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 1436065 - Add JS_NewLatin1String API to create Latin1 strings without copying. r=luke
js/src/jsapi.cpp
js/src/jsapi.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -5839,16 +5839,24 @@ JS_AtomizeAndPinStringN(JSContext* cx, c
     AssertHeapIsIdle();
     CHECK_REQUEST(cx);
     JSAtom* atom = Atomize(cx, s, length, PinAtom);
     MOZ_ASSERT_IF(atom, JS_StringHasBeenPinned(cx, atom));
     return atom;
 }
 
 JS_PUBLIC_API(JSString*)
+JS_NewLatin1String(JSContext* cx, JS::Latin1Char* chars, size_t length)
+{
+    AssertHeapIsIdle();
+    CHECK_REQUEST(cx);
+    return NewString<CanGC>(cx, chars, length);
+}
+
+JS_PUBLIC_API(JSString*)
 JS_NewUCString(JSContext* cx, char16_t* chars, size_t length)
 {
     AssertHeapIsIdle();
     CHECK_REQUEST(cx);
     return NewString<CanGC>(cx, chars, length);
 }
 
 JS_PUBLIC_API(JSString*)
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4718,16 +4718,19 @@ JS_AtomizeString(JSContext* cx, const ch
 
 extern JS_PUBLIC_API(JSString*)
 JS_AtomizeAndPinStringN(JSContext* cx, const char* s, size_t length);
 
 extern JS_PUBLIC_API(JSString*)
 JS_AtomizeAndPinString(JSContext* cx, const char* s);
 
 extern JS_PUBLIC_API(JSString*)
+JS_NewLatin1String(JSContext* cx, JS::Latin1Char* chars, size_t length);
+
+extern JS_PUBLIC_API(JSString*)
 JS_NewUCString(JSContext* cx, char16_t* chars, size_t length);
 
 extern JS_PUBLIC_API(JSString*)
 JS_NewUCStringCopyN(JSContext* cx, const char16_t* s, size_t n);
 
 extern JS_PUBLIC_API(JSString*)
 JS_NewUCStringCopyZ(JSContext* cx, const char16_t* s);