Backed out changeset 2693283b5d8b (bug 1142814) for bc1 orange

This commit is contained in:
Wes Kocher 2015-03-16 17:45:45 -07:00
parent 7395e6dd6c
commit 4a1d74cfc0
3 changed files with 1 additions and 59 deletions

View File

@ -4022,44 +4022,15 @@ js::StringConstructor(JSContext *cx, unsigned argc, Value *vp)
return true;
}
static bool
str_fromCharCode_few_args(JSContext *cx, const CallArgs &args)
{
MOZ_ASSERT(args.length() <= JSFatInlineString::MAX_LENGTH_TWO_BYTE);
char16_t chars[JSFatInlineString::MAX_LENGTH_TWO_BYTE];
for (unsigned i = 0; i < args.length(); i++) {
uint16_t code;
if (!ToUint16(cx, args[i], &code))
return false;
chars[i] = char16_t(code);
}
JSString *str = NewStringCopyN<CanGC>(cx, chars, args.length());
if (!str)
return false;
args.rval().setString(str);
return true;
}
bool
js::str_fromCharCode(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
MOZ_ASSERT(args.length() <= ARGS_LENGTH_MAX);
// Optimize the single-char case.
if (args.length() == 1)
return str_fromCharCode_one_arg(cx, args[0], args.rval());
// Optimize the case where the result will definitely fit in an inline
// string (thin or fat) and so we don't need to malloc the chars. (We could
// cover some cases where args.length() goes up to
// JSFatInlineString::MAX_LENGTH_LATIN1 if we also checked if the chars are
// all Latin1, but it doesn't seem worth the effort.)
if (args.length() <= JSFatInlineString::MAX_LENGTH_TWO_BYTE)
return str_fromCharCode_few_args(cx, args);
char16_t *chars = cx->pod_malloc<char16_t>(args.length() + 1);
if (!chars)
return false;

View File

@ -153,24 +153,4 @@ new TestCase( SECTION, "String.fromCharCode(0x007D)", "}", String.fromCh
new TestCase( SECTION, "String.fromCharCode(0x007E)", "~", String.fromCharCode(0x007E) );
// new TestCase( SECTION, "String.fromCharCode(0x0020, 0x007F)", "", String.fromCharCode(0x0040, 0x007F) );
new TestCase( SECTION, "String.fromCharCode(<2 args>)", "ab", String.fromCharCode(97,98));
new TestCase( SECTION, "String.fromCharCode(<3 args>)", "abc", String.fromCharCode(97,98,99));
new TestCase( SECTION, "String.fromCharCode(<4 args>)", "abcd", String.fromCharCode(97,98,99,100));
new TestCase( SECTION, "String.fromCharCode(<5 args>)", "abcde", String.fromCharCode(97,98,99,100,101));
new TestCase( SECTION, "String.fromCharCode(<6 args>)", "abcdef", String.fromCharCode(97,98,99,100,101,102));
new TestCase( SECTION, "String.fromCharCode(<7 args>)", "abcdefg", String.fromCharCode(97,98,99,100,101,102,103));
new TestCase( SECTION, "String.fromCharCode(<8 args>)", "abcdefgh", String.fromCharCode(97,98,99,100,101,102,103,104));
new TestCase( SECTION, "String.fromCharCode(<9 args>)", "abcdefghi", String.fromCharCode(97,98,99,100,101,102,103,104,105));
new TestCase( SECTION, "String.fromCharCode(<10 args>)", "abcdefghij", String.fromCharCode(97,98,99,100,101,102,103,104,105,106));
new TestCase( SECTION, "String.fromCharCode(<11 args>)", "abcdefghijk", String.fromCharCode(97,98,99,100,101,102,103,104,105,106,107));
new TestCase( SECTION, "String.fromCharCode(<12 args>)", "abcdefghijkl", String.fromCharCode(97,98,99,100,101,102,103,104,105,106,107,108));
new TestCase( SECTION, "String.fromCharCode(<13 args>)", "abcdefghijklm", String.fromCharCode(97,98,99,100,101,102,103,104,105,106,107,108,109));
new TestCase( SECTION, "String.fromCharCode(<14 args>)", "abcdefghijklmn", String.fromCharCode(97,98,99,100,101,102,103,104,105,106,107,108,109,110));
new TestCase( SECTION, "String.fromCharCode(<15 args>)", "abcdefghijklmno", String.fromCharCode(97,98,99,100,101,102,103,104,105,106,107,108,109,110,111));
new TestCase( SECTION, "String.fromCharCode(<16 args>)", "abcdefghijklmnop", String.fromCharCode(97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112));
new TestCase( SECTION, "String.fromCharCode(<17 args>)", "abcdefghijklmnopq", String.fromCharCode(97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113));
new TestCase( SECTION, "String.fromCharCode(<18 args>)", "abcdefghijklmnopqr", String.fromCharCode(97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114));
new TestCase( SECTION, "String.fromCharCode(<19 args>)", "abcdefghijklmnopqrs", String.fromCharCode(97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115));
new TestCase( SECTION, "String.fromCharCode(<20 args>)", "abcdefghijklmnopqrst", String.fromCharCode(97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116));
test();

View File

@ -624,14 +624,6 @@
let JSDOMParser = function () {
this.currentChar = 0;
// In makeElementNode() we build up many strings one char at a time. Using
// += for this results in lots of short-lived intermediate strings. It's
// better to build an array of single-char strings and then join() them
// together at the end. And reusing a single array (i.e. |this.strBuf|)
// over and over for this purpose uses less memory than using a new array
// for each string.
this.strBuf = [];
};
JSDOMParser.prototype = {
@ -716,8 +708,7 @@
let c = this.nextChar();
// Read the Element tag name
let strBuf = this.strBuf;
strBuf.length = 0;
let tag = "";
while (c !== " " && c !== ">" && c !== "/") {
if (c === undefined)
return null;