Don't bother spending time to root the jsval if it's a string -- in this case

we make a copy of the string data anyway, so we don't need the jsval.  Bug
311582, r+sr=jst
This commit is contained in:
bzbarsky%mit.edu 2006-09-20 01:21:25 +00:00
parent 6ab569a8bf
commit ce51ad8bb6

View File

@ -53,8 +53,10 @@ XPCVariant::XPCVariant()
XPCVariant::~XPCVariant()
{
nsVariant::Cleanup(&mData);
if(JSVAL_IS_GCTHING(mJSVal))
// We don't root strings; see comments in newVariant. Note that even if
// the string went away testing JSVAL_IS_STRING(mJSVal) is safe.
if(JSVAL_IS_GCTHING(mJSVal) && !JSVAL_IS_STRING(mJSVal))
{
JSRuntime* rt;
nsIJSRuntimeService* rtsrvc = nsXPConnect::GetJSRuntimeService();
@ -75,7 +77,9 @@ XPCVariant* XPCVariant::newVariant(XPCCallContext& ccx, jsval aJSVal)
variant->mJSVal = aJSVal;
if(JSVAL_IS_GCTHING(variant->mJSVal))
// We don't need to root mJSVal if it's a string -- in that case we'll just
// make a copy of the string data.
if(JSVAL_IS_GCTHING(variant->mJSVal) && !JSVAL_IS_STRING(variant->mJSVal))
{
JSRuntime* rt;
if(NS_FAILED(ccx.GetRuntime()->GetJSRuntimeService()->GetRuntime(&rt))||