Bug 1376477 - Use Lookup instead of Get+Remove to avoid unnecessary hashtable lookups. Replace Get with Contains to avoid ref-counting. r=froydnj
authorMats Palmgren <mats@mozilla.com>
Wed, 28 Jun 2017 01:03:17 +0200
changeset 366344 06832382e6184a071c47f6aed86e3c96c502fb36
parent 366343 3de0dd0420012199cf450d40c74ed4c493b45981
child 366345 cde0e881e5b5127daea2f44f8cc1cf2ecebe1bc1
push id32099
push usercbook@mozilla.com
push dateWed, 28 Jun 2017 11:23:49 +0000
treeherdermozilla-central@306d2070e105 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1376477
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
xpcom/ds/nsProperties.cpp
--- a/xpcom/ds/nsProperties.cpp
+++ b/xpcom/ds/nsProperties.cpp
@@ -39,34 +39,31 @@ nsProperties::Set(const char* prop, nsIS
 
 NS_IMETHODIMP
 nsProperties::Undefine(const char* prop)
 {
   if (NS_WARN_IF(!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
 nsProperties::Has(const char* prop, bool* result)
 {
   if (NS_WARN_IF(!prop)) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  nsCOMPtr<nsISupports> value;
-  *result = nsProperties_HashBase::Get(prop, getter_AddRefs(value));
+  *result = nsProperties_HashBase::Contains(prop);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsProperties::GetKeys(uint32_t* aCount, char*** aKeys)
 {
   if (NS_WARN_IF(!aCount) || NS_WARN_IF(!aKeys)) {
     return NS_ERROR_INVALID_ARG;