Object.prototype.toString() should use cached strings for null/undefined.
[WebKit-https.git] / Source / JavaScriptCore / runtime / ObjectPrototype.cpp
index 7daf0d6..ecd339a 100644 (file)
@@ -215,7 +215,7 @@ EncodedJSValue JSC_HOST_CALL objectProtoFuncToString(ExecState* exec)
     VM& vm = exec->vm();
     JSValue thisValue = exec->thisValue().toThis(exec, StrictMode);
     if (thisValue.isUndefinedOrNull())
-        return JSValue::encode(jsNontrivialString(&vm, String(thisValue.isUndefined() ? ASCIILiteral("[object Undefined]") : ASCIILiteral("[object Null]"))));
+        return JSValue::encode(thisValue.isUndefined() ? vm.smallStrings.undefinedObjectString() : vm.smallStrings.nullObjectString());
     JSObject* thisObject = thisValue.toObject(exec);
 
     JSString* result = thisObject->structure(vm)->objectToStringValue();