Bug 1370700 part 1 - Use mAttributeCache.LookupRemoveIf() to avoid a second hashtable lookup for Remove(). r=froydnj

MozReview-Commit-ID: CrIb6DcE1D7
This commit is contained in:
Mats Palmgren 2017-06-07 20:03:19 +02:00
parent e6ddf2c3c1
commit 6cdee8c35e

View File

@ -118,14 +118,11 @@ void
nsDOMAttributeMap::DropAttribute(int32_t aNamespaceID, nsIAtom* aLocalName)
{
nsAttrKey attr(aNamespaceID, aLocalName);
Attr *node = mAttributeCache.GetWeak(attr);
if (node) {
// Break link to map
node->SetMap(nullptr);
// Remove from cache
mAttributeCache.Remove(attr);
}
mAttributeCache.LookupRemoveIf(attr,
[] (Attr* aNode) {
aNode->SetMap(nullptr); // break link to map
return true; // remove from cache
});
}
Attr*