Bug 707061 - Rename js_ValueToString to ToString. Also, consistent with ToObject, make ToString include an inline already-string fast path, and make ToStringSlow be an out-of-line slow path for the case where the value is not a string (asserting that this is the case). r=luke

This commit is contained in:
Jeff Walden
2011-12-01 19:35:44 -08:00
parent 0c1c9fe724
commit 477d66175a
22 changed files with 113 additions and 108 deletions

View File

@@ -1190,7 +1190,7 @@ date_parse(JSContext *cx, uintN argc, Value *vp)
vp->setDouble(js_NaN);
return true;
}
str = js_ValueToString(cx, vp[2]);
str = ToString(cx, vp[2]);
if (!str)
return JS_FALSE;
vp[2].setString(str);
@@ -2417,7 +2417,7 @@ date_toLocaleFormat(JSContext *cx, uintN argc, Value *vp)
if (!obj)
return ok;
JSString *fmt = js_ValueToString(cx, args[0]);
JSString *fmt = ToString(cx, args[0]);
if (!fmt)
return false;
@@ -2511,7 +2511,7 @@ date_valueOf(JSContext *cx, uintN argc, Value *vp)
}
/* Convert to number only if the hint was given, otherwise favor string. */
JSString *str = js_ValueToString(cx, args[0]);
JSString *str = ToString(cx, args[0]);
if (!str)
return false;
JSLinearString *linear_str = str->ensureLinear(cx);
@@ -2606,7 +2606,7 @@ js_Date(JSContext *cx, uintN argc, Value *vp)
d = TIMECLIP(d);
} else {
/* the argument is a string; parse it. */
JSString *str = js_ValueToString(cx, args[0]);
JSString *str = ToString(cx, args[0]);
if (!str)
return false;
args[0].setString(str);