Bug 1376473 - Use Lookup instead of Get+Remove to avoid unnecessary hashtable lookups. r=froydnj

MozReview-Commit-ID: lWNPPBDNh7
This commit is contained in:
Mats Palmgren 2017-06-28 01:03:17 +02:00
parent e7a32e265e
commit 59d3163a68

View File

@ -61,18 +61,11 @@ nsHashPropertyBagBase::SetProperty(const nsAString& aName, nsIVariant* aValue)
NS_IMETHODIMP
nsHashPropertyBagBase::DeleteProperty(const nsAString& aName)
{
// is it too much to ask for ns*Hashtable to return
// a boolean indicating whether RemoveEntry succeeded
// or not?!?!
bool isFound = mPropertyHash.Get(aName, nullptr);
if (!isFound) {
return NS_ERROR_FAILURE;
if (auto entry = mPropertyHash.Lookup(aName)) {
entry.Remove();
return NS_OK;
}
// then from the hash
mPropertyHash.Remove(aName);
return NS_OK;
return NS_ERROR_FAILURE;
}