Bug 518230 - Use CESU-8 and refer to previous strings, r=igor

This commit is contained in:
Michael Wu
2011-03-21 11:06:34 -07:00
parent b6692b4b8b
commit 5095cd1a65
9 changed files with 179 additions and 112 deletions

View File

@@ -521,7 +521,7 @@ js_AtomizeString(JSContext *cx, JSString *strArg, uintN flags)
}
JSAtom *
js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags)
js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags, bool useCESU8)
{
jschar *chars;
JSString str;
@@ -541,12 +541,15 @@ js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags)
size_t inflatedLength = ATOMIZE_BUF_MAX - 1;
if (length < ATOMIZE_BUF_MAX) {
js_InflateStringToBuffer(cx, bytes, length, inflated, &inflatedLength);
if (useCESU8)
js_InflateUTF8StringToBuffer(cx, bytes, length, inflated, &inflatedLength, true);
else
js_InflateStringToBuffer(cx, bytes, length, inflated, &inflatedLength);
inflated[inflatedLength] = 0;
chars = inflated;
} else {
inflatedLength = length;
chars = js_InflateString(cx, bytes, &inflatedLength);
chars = js_InflateString(cx, bytes, &inflatedLength, useCESU8);
if (!chars)
return NULL;
flags |= ATOM_NOCOPY;