Bug 1037264 - Add an 8-bit short-lived string cache. r=neil

This commit is contained in:
Bobby Holley 2014-07-15 16:30:51 -07:00
parent a6be42fa2f
commit 334ef7dc92
2 changed files with 3 additions and 5 deletions

View File

@ -2324,10 +2324,7 @@ CallMethodHelper::CleanupParam(nsXPTCMiniVariant& param, nsXPTType& type)
break;
case nsXPTType::T_UTF8STRING:
case nsXPTType::T_CSTRING:
{
nsCString* rs = (nsCString*)param.val.p;
delete rs;
}
nsXPConnect::GetRuntimeInstance()->mScratchCStrings.Destroy((nsCString*)param.val.p);
break;
default:
MOZ_ASSERT(!type.IsArithmetic(), "Cleanup requested on unexpected type.");
@ -2355,7 +2352,7 @@ CallMethodHelper::AllocateStringClass(nsXPTCVariant* dp,
if (type_tag == nsXPTType::T_ASTRING || type_tag == nsXPTType::T_DOMSTRING)
dp->val.p = nsXPConnect::GetRuntimeInstance()->mScratchStrings.Create();
else
dp->val.p = new nsCString();
dp->val.p = nsXPConnect::GetRuntimeInstance()->mScratchCStrings.Create();
// Check for OOM, in either case.
if (!dp->val.p) {

View File

@ -593,6 +593,7 @@ public:
~XPCJSRuntime();
ShortLivedStringBuffer<nsString> mScratchStrings;
ShortLivedStringBuffer<nsCString> mScratchCStrings;
void AddGCCallback(xpcGCCallback cb);
void RemoveGCCallback(xpcGCCallback cb);