Bug 1347369 - Avoid dynamic allocation of URLParams in OriginAttributes methods; r=baku

These show up in some profiles sometimes, and there is no reason why
the variables can't simply live on the stack.
This commit is contained in:
Ehsan Akhgari 2017-03-14 21:11:36 -04:00
Родитель e981884dca
Коммит 15bd78db3c
1 изменённых файлов: 10 добавлений и 10 удалений

Просмотреть файл

@ -99,7 +99,7 @@ OriginAttributes::SetFirstPartyDomain(const bool aIsTopLevelDocument,
void
OriginAttributes::CreateSuffix(nsACString& aStr) const
{
UniquePtr<URLParams> params(new URLParams());
URLParams params;
nsAutoString value;
//
@ -111,34 +111,34 @@ OriginAttributes::CreateSuffix(nsACString& aStr) const
if (mAppId != nsIScriptSecurityManager::NO_APP_ID) {
value.AppendInt(mAppId);
params->Set(NS_LITERAL_STRING("appId"), value);
params.Set(NS_LITERAL_STRING("appId"), value);
}
if (mInIsolatedMozBrowser) {
params->Set(NS_LITERAL_STRING("inBrowser"), NS_LITERAL_STRING("1"));
params.Set(NS_LITERAL_STRING("inBrowser"), NS_LITERAL_STRING("1"));
}
if (mUserContextId != nsIScriptSecurityManager::DEFAULT_USER_CONTEXT_ID) {
value.Truncate();
value.AppendInt(mUserContextId);
params->Set(NS_LITERAL_STRING("userContextId"), value);
params.Set(NS_LITERAL_STRING("userContextId"), value);
}
if (mPrivateBrowsingId) {
value.Truncate();
value.AppendInt(mPrivateBrowsingId);
params->Set(NS_LITERAL_STRING("privateBrowsingId"), value);
params.Set(NS_LITERAL_STRING("privateBrowsingId"), value);
}
if (!mFirstPartyDomain.IsEmpty()) {
MOZ_RELEASE_ASSERT(mFirstPartyDomain.FindCharInSet(dom::quota::QuotaManager::kReplaceChars) == kNotFound);
params->Set(NS_LITERAL_STRING("firstPartyDomain"), mFirstPartyDomain);
params.Set(NS_LITERAL_STRING("firstPartyDomain"), mFirstPartyDomain);
}
aStr.Truncate();
params->Serialize(value);
params.Serialize(value);
if (!value.IsEmpty()) {
aStr.AppendLiteral("^");
aStr.Append(NS_ConvertUTF16toUTF8(value));
@ -255,11 +255,11 @@ OriginAttributes::PopulateFromSuffix(const nsACString& aStr)
return false;
}
UniquePtr<URLParams> params(new URLParams());
params->ParseInput(Substring(aStr, 1, aStr.Length() - 1));
URLParams params;
params.ParseInput(Substring(aStr, 1, aStr.Length() - 1));
PopulateFromSuffixIterator iterator(this);
return params->ForEach(iterator);
return params.ForEach(iterator);
}
bool