Bug 1376477 - Use Lookup instead of Get+Remove to avoid unnecessary hashtable lookups. Replace Get with Contains to avoid ref-counting. r=froydnj

MozReview-Commit-ID: G4F2pAnNA73
This commit is contained in:
Mats Palmgren 2017-06-28 01:03:17 +02:00
Родитель e0fc464fa9
Коммит 30c6d6295a
1 изменённых файлов: 5 добавлений и 8 удалений

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

@ -44,13 +44,11 @@ nsProperties::Undefine(const char* prop)
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsISupports> value;
if (!nsProperties_HashBase::Get(prop, getter_AddRefs(value))) {
return NS_ERROR_FAILURE;
if (auto entry = nsProperties_HashBase::Lookup(prop)) {
entry.Remove();
return NS_OK;
}
Remove(prop);
return NS_OK;
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
@ -60,8 +58,7 @@ nsProperties::Has(const char* prop, bool* result)
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsISupports> value;
*result = nsProperties_HashBase::Get(prop, getter_AddRefs(value));
*result = nsProperties_HashBase::Contains(prop);
return NS_OK;
}