зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1371952 - Use LookupForAdd/LookupRemoveIf to avoid unnecessary hashtable lookups. r=froydnj
MozReview-Commit-ID: 5hprMT4Gc42
This commit is contained in:
Родитель
68da6780f3
Коммит
2ee1457c5b
|
@ -453,14 +453,16 @@ already_AddRefed<ParticularProcessPriorityManager>
|
|||
ProcessPriorityManagerImpl::GetParticularProcessPriorityManager(
|
||||
ContentParent* aContentParent)
|
||||
{
|
||||
RefPtr<ParticularProcessPriorityManager> pppm;
|
||||
uint64_t cpId = aContentParent->ChildID();
|
||||
mParticularManagers.Get(cpId, &pppm);
|
||||
if (!pppm) {
|
||||
pppm = new ParticularProcessPriorityManager(aContentParent);
|
||||
pppm->Init();
|
||||
mParticularManagers.Put(cpId, pppm);
|
||||
auto entry = mParticularManagers.LookupForAdd(cpId);
|
||||
RefPtr<ParticularProcessPriorityManager> pppm = entry.OrInsert(
|
||||
[aContentParent]() {
|
||||
return new ParticularProcessPriorityManager(aContentParent);
|
||||
});
|
||||
|
||||
if (!entry) {
|
||||
// We created a new entry.
|
||||
pppm->Init();
|
||||
FireTestOnlyObserverNotification("process-created",
|
||||
nsPrintfCString("%" PRIu64, cpId));
|
||||
}
|
||||
|
@ -501,15 +503,12 @@ ProcessPriorityManagerImpl::ObserveContentParentDestroyed(nsISupports* aSubject)
|
|||
props->GetPropertyAsUint64(NS_LITERAL_STRING("childID"), &childID);
|
||||
NS_ENSURE_TRUE_VOID(childID != CONTENT_PROCESS_ID_UNKNOWN);
|
||||
|
||||
RefPtr<ParticularProcessPriorityManager> pppm;
|
||||
mParticularManagers.Get(childID, &pppm);
|
||||
if (pppm) {
|
||||
pppm->ShutDown();
|
||||
|
||||
mParticularManagers.Remove(childID);
|
||||
|
||||
mHighPriorityChildIDs.RemoveEntry(childID);
|
||||
}
|
||||
mParticularManagers.LookupRemoveIf(childID,
|
||||
[this, childID] (RefPtr<ParticularProcessPriorityManager>& aValue) {
|
||||
aValue->ShutDown();
|
||||
mHighPriorityChildIDs.RemoveEntry(childID);
|
||||
return true; // remove it
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Загрузка…
Ссылка в новой задаче