mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-04 15:51:37 +00:00
Bug 1376473 - Use Lookup instead of Get+Remove to avoid unnecessary hashtable lookups. r=froydnj
MozReview-Commit-ID: lWNPPBDNh7
This commit is contained in:
parent
e7a32e265e
commit
59d3163a68
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user