Bug 934817 - Part 1: JS_New*StringCopyN should do 0-length optimization. r=luke

This commit is contained in:
Michael Shuen 2014-02-14 11:15:42 -05:00
parent d5170f6988
commit a094223027

View File

@ -5126,6 +5126,8 @@ JS_NewStringCopyN(JSContext *cx, const char *s, size_t n)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
if (!n)
return cx->names().empty;
return js_NewStringCopyN<CanGC>(cx, s, n);
}
@ -5210,6 +5212,8 @@ JS_NewUCStringCopyN(JSContext *cx, const jschar *s, size_t n)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
if (!n)
return cx->names().empty;
return js_NewStringCopyN<CanGC>(cx, s, n);
}