Make js_ValueToString inline (503669, r=jwalden).

This commit is contained in:
Andreas Gal
2009-07-13 14:55:04 -07:00
parent c3f1c37d69
commit 6e32ef4468
13 changed files with 116 additions and 51 deletions

View File

@@ -838,38 +838,6 @@ js_AtomizePrimitiveValue(JSContext *cx, jsval v, JSAtom **atomp)
return JS_TRUE;
}
JSBool
js_ValueToStringId(JSContext *cx, jsval v, jsid *idp)
{
JSString *str;
JSAtom *atom;
/*
* Optimize for the common case where v is an already-atomized string. The
* comment in jsstr.h before JSString::flatSetAtomized explains why this is
* thread-safe. The extra rooting via lastAtom (which would otherwise be
* done in js_js_AtomizeString) ensures the caller that the resulting id at
* is least weakly rooted.
*/
if (JSVAL_IS_STRING(v)) {
str = JSVAL_TO_STRING(v);
if (str->isAtomized()) {
cx->weakRoots.lastAtom = v;
*idp = ATOM_TO_JSID((JSAtom *) v);
return JS_TRUE;
}
} else {
str = js_ValueToString(cx, v);
if (!str)
return JS_FALSE;
}
atom = js_AtomizeString(cx, str, 0);
if (!atom)
return JS_FALSE;
*idp = ATOM_TO_JSID(atom);
return JS_TRUE;
}
#ifdef DEBUG
static JSDHashOperator