Atomize unit strings at birth (511567, r=shaver).

This commit is contained in:
Andreas Gal
2009-08-19 19:37:59 -07:00
parent cf82fdaf70
commit 07dfc0fbc3
3 changed files with 19 additions and 1 deletions

View File

@@ -673,6 +673,12 @@ js_AtomizeString(JSContext *cx, JSString *str, uintN flags)
JS_ASSERT(!(flags & ~(ATOM_PINNED|ATOM_INTERNED|ATOM_TMPSTR|ATOM_NOCOPY)));
JS_ASSERT_IF(flags & ATOM_NOCOPY, flags & ATOM_TMPSTR);
if (str->length() == 1) {
jschar c = str->chars()[0];
if (c < UNIT_STRING_LIMIT)
return (JSAtom*) STRING_TO_JSVAL(js_GetUnitStringForChar(cx, c));
}
state = &cx->runtime->atomState;
table = &state->stringAtoms;