mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 966264 - Don't allocate new "[object Foo]" strings for the most common classes. r=njn
This commit is contained in:
parent
808b00705b
commit
80f041fdbf
@ -272,8 +272,24 @@ js::ObjectToSource(JSContext *cx, HandleObject obj)
|
||||
JSString *
|
||||
JS_BasicObjectToString(JSContext *cx, HandleObject obj)
|
||||
{
|
||||
// Some classes are really common, don't allocate new strings for them.
|
||||
// The ordering below is based on the measurements in bug 966264.
|
||||
if (obj->is<JSObject>())
|
||||
return cx->names().objectObject;
|
||||
if (obj->is<StringObject>())
|
||||
return cx->names().objectString;
|
||||
if (obj->is<ArrayObject>())
|
||||
return cx->names().objectArray;
|
||||
if (obj->is<JSFunction>())
|
||||
return cx->names().objectFunction;
|
||||
if (obj->is<NumberObject>())
|
||||
return cx->names().objectNumber;
|
||||
|
||||
const char *className = JSObject::className(cx, obj);
|
||||
|
||||
if (strcmp(className, "Window") == 0)
|
||||
return cx->names().objectWindow;
|
||||
|
||||
StringBuffer sb(cx);
|
||||
if (!sb.append("[object ") || !sb.appendInflated(className, strlen(className)) ||
|
||||
!sb.append("]"))
|
||||
|
@ -129,8 +129,14 @@
|
||||
macro(NumberFormat, NumberFormat, "NumberFormat") \
|
||||
macro(NumberFormatFormatGet, NumberFormatFormatGet, "Intl_NumberFormat_format_get") \
|
||||
macro(numeric, numeric, "numeric") \
|
||||
macro(objectArray, objectArray, "[object Array]") \
|
||||
macro(objectFunction, objectFunction, "[object Function]") \
|
||||
macro(objectNull, objectNull, "[object Null]") \
|
||||
macro(objectNumber, objectNumber, "[object Number]") \
|
||||
macro(objectObject, objectObject, "[object Object]") \
|
||||
macro(objectString, objectString, "[object String]") \
|
||||
macro(objectUndefined, objectUndefined, "[object Undefined]") \
|
||||
macro(objectWindow, objectWindow, "[object Window]") \
|
||||
macro(of, of, "of") \
|
||||
macro(offset, offset, "offset") \
|
||||
macro(outOfMemory, outOfMemory, "out of memory") \
|
||||
|
Loading…
Reference in New Issue
Block a user