forked from mirrors/0ad
SpiderMonkey 38 upgrade: 32/35
JS_GetStringCharsAndLength was removed, use
JS_Get{Latin1,TwoByte}StringCharsAndLength instead.
Actually handle strings in both the Latin1 and TwoByte cases since we
need to.
This saves some space when serializing and also when running as they are
stored that way in the vm.
Also handle the error case.
Patch by leper.
For more information:
https://blog.mozilla.org/javascript/2014/07/21/slimmer-and-faster-javascript-strings-in-firefox/
Addresses https://bugzilla.mozilla.org/show_bug.cgi?id=1037869
This was SVN commit r18686.
This commit is contained in:
@@ -783,9 +783,22 @@ bool ScriptInterface::EnumeratePropertyNamesWithPrefix(JS::HandleValue objVal, c
|
||||
buf[len-1]= '\0';
|
||||
if (0 == strcmp(&buf[0], prefix))
|
||||
{
|
||||
size_t len;
|
||||
const char16_t* chars = JS_GetStringCharsAndLength(m->m_cx, name, &len);
|
||||
out.push_back(std::string(chars, chars+len));
|
||||
if (JS_StringHasLatin1Chars(name))
|
||||
{
|
||||
size_t length;
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
const JS::Latin1Char* chars = JS_GetLatin1StringCharsAndLength(m->m_cx, nogc, name, &length);
|
||||
if (chars)
|
||||
out.push_back(std::string(chars, chars+length));
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t length;
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
const char16_t* chars = JS_GetTwoByteStringCharsAndLength(m->m_cx, nogc, name, &length);
|
||||
if (chars)
|
||||
out.push_back(std::string(chars, chars+length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user