js_GetExistingStringAtom should check for unit strings (512996, r=jorendorff).

This commit is contained in:
Andreas Gal
2009-08-28 15:53:55 -07:00
parent fbbc065641
commit d519506f6e

View File

@@ -823,6 +823,14 @@ js_GetExistingStringAtom(JSContext *cx, const jschar *chars, size_t length)
JSAtomState *state;
JSDHashEntryHdr *hdr;
if (length == 1) {
jschar c = *chars;
if (c < UNIT_STRING_LIMIT) {
JSString *str = js_GetUnitStringForChar(cx, c);
return str ? (JSAtom *) STRING_TO_JSVAL(str) : NULL;
}
}
str.initFlat((jschar *)chars, length);
state = &cx->runtime->atomState;