Bug 1372349 - Use LookupForAdd instead of GetWeak+Put to avoid unnecessary hashtable lookups. r=froydnj
MozReview-Commit-ID: 37FVkb3vOO4
This commit is contained in:
@@ -111,15 +111,12 @@ DocAllResultMatch(Element* aElement, int32_t aNamespaceID, nsIAtom* aAtom,
|
||||
nsContentList*
|
||||
HTMLAllCollection::GetDocumentAllList(const nsAString& aID)
|
||||
{
|
||||
if (nsContentList* docAllList = mNamedMap.GetWeak(aID)) {
|
||||
return docAllList;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> id = NS_Atomize(aID);
|
||||
RefPtr<nsContentList> docAllList =
|
||||
new nsContentList(mDocument, DocAllResultMatch, nullptr, nullptr, true, id);
|
||||
mNamedMap.Put(aID, docAllList);
|
||||
return docAllList;
|
||||
return mNamedMap.LookupForAdd(aID).OrInsert(
|
||||
[this, &aID] () {
|
||||
nsCOMPtr<nsIAtom> id = NS_Atomize(aID);
|
||||
return new nsContentList(mDocument, DocAllResultMatch, nullptr,
|
||||
nullptr, true, id);
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user