зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1376038 - Part 2: Cache base domains during ghost window calculation. r=mccr8
Avoid hitting the rather slow effective TLD service by caching results when mapping URLs to their base domains. In testing the cache ranged from a 1:1 to a 3:1 hit:miss ratio. --HG-- extra : histedit_source : 9692a36bb32474b6de0a8291ceb9af7a19d221ff
This commit is contained in:
Родитель
197f29015a
Коммит
c56ea2d3d6
|
@ -922,6 +922,7 @@ nsWindowMemoryReporter::CheckForGhostWindows(
|
|||
KillCheckTimer();
|
||||
|
||||
nsTHashtable<nsCStringHashKey> nonDetachedWindowDomains;
|
||||
nsDataHashtable<nsISupportsHashKey, nsCString> domainMap;
|
||||
|
||||
// Populate nonDetachedWindowDomains.
|
||||
for (auto iter = windowsById->Iter(); !iter.Done(); iter.Next()) {
|
||||
|
@ -936,8 +937,13 @@ nsWindowMemoryReporter::CheckForGhostWindows(
|
|||
nsCOMPtr<nsIURI> uri = GetWindowURI(window);
|
||||
nsAutoCString domain;
|
||||
if (uri) {
|
||||
tldService->GetBaseDomain(uri, 0, domain);
|
||||
domain = domainMap.LookupForAdd(uri).OrInsert([&]() {
|
||||
nsCString d;
|
||||
tldService->GetBaseDomain(uri, 0, d);
|
||||
return d;
|
||||
});
|
||||
}
|
||||
|
||||
nonDetachedWindowDomains.PutEntry(domain);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче