Bug 1372022 - Replace a series of Contains+Put+Get+Put hashtable lookups with a single LookupForAdd call. r=froydnj

MozReview-Commit-ID: GOSe2Ztahlr
This commit is contained in:
Mats Palmgren 2017-06-14 01:54:27 +02:00
Родитель 2dffd04a1b
Коммит a821681287
1 изменённых файлов: 9 добавлений и 6 удалений

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

@ -1719,12 +1719,15 @@ nsDisplayListBuilder::AddToWillChangeBudget(nsIFrame* aFrame,
}
nsPresContext* key = aFrame->PresContext();
if (!mWillChangeBudget.Contains(key)) {
mWillChangeBudget.Put(key, DocumentWillChangeBudget());
}
DocumentWillChangeBudget budget;
mWillChangeBudget.Get(key, &budget);
auto willChangeBudgetEntry = mWillChangeBudget.LookupForAdd(key);
if (willChangeBudgetEntry) {
// We have an existing entry.
budget = willChangeBudgetEntry.Data();
} else {
budget = DocumentWillChangeBudget();
willChangeBudgetEntry.OrInsert([&budget] () { return budget; });
}
nsRect area = aFrame->PresContext()->GetVisibleArea();
uint32_t budgetLimit = nsPresContext::AppUnitsToIntCSSPixels(area.width) *
@ -1736,7 +1739,7 @@ nsDisplayListBuilder::AddToWillChangeBudget(nsIFrame* aFrame,
if (onBudget) {
budget.mBudget += cost;
mWillChangeBudget.Put(key, budget);
willChangeBudgetEntry.Data() = budget;
mWillChangeBudgetSet.PutEntry(aFrame);
}