Bug 1372327 - Use LookupForAdd instead of Get+Put to avoid unnecessary hashtable lookups. r=froydnj

MozReview-Commit-ID: 5J6Ea73JX4f
This commit is contained in:
Mats Palmgren 2017-06-14 17:27:25 +02:00
parent 2979d4b762
commit 185a60c094

View File

@ -380,12 +380,13 @@ EventListenerService::NotifyAboutMainThreadListenerChangeInternal(dom::EventTarg
}
}
RefPtr<EventListenerChange> changes = mPendingListenerChangesSet.Get(aTarget);
if (!changes) {
changes = new EventListenerChange(aTarget);
mPendingListenerChanges->AppendElement(changes, false);
mPendingListenerChangesSet.Put(aTarget, changes);
}
RefPtr<EventListenerChange> changes =
mPendingListenerChangesSet.LookupForAdd(aTarget).OrInsert(
[this, aTarget] () {
EventListenerChange* c = new EventListenerChange(aTarget);
mPendingListenerChanges->AppendElement(c, false);
return c;
});
changes->AddChangedListenerName(aName);
}