Bug 1376127 - Use LookupForAdd instead of Get+Put in CycleCollectedJSRuntime::DeferredFinalize to avoid unnecessary hashtable lookups. r=froydnj
MozReview-Commit-ID: 1lEnh9yTQUH
This commit is contained in:
@@ -1246,12 +1246,11 @@ CycleCollectedJSRuntime::DeferredFinalize(DeferredFinalizeAppendFunction aAppend
|
||||
DeferredFinalizeFunction aFunc,
|
||||
void* aThing)
|
||||
{
|
||||
void* thingArray = nullptr;
|
||||
bool hadThingArray = mDeferredFinalizerTable.Get(aFunc, &thingArray);
|
||||
|
||||
thingArray = aAppendFunc(thingArray, aThing);
|
||||
if (!hadThingArray) {
|
||||
mDeferredFinalizerTable.Put(aFunc, thingArray);
|
||||
if (auto entry = mDeferredFinalizerTable.LookupForAdd(aFunc)) {
|
||||
aAppendFunc(entry.Data(), aThing);
|
||||
} else {
|
||||
entry.OrInsert(
|
||||
[aAppendFunc, aThing] () { return aAppendFunc(nullptr, aThing); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user