Bug 1371061 - Optimize nsBaseHashtable::GetOrInsert() to only do a single hashtable lookup. r=froydnj
authorMats Palmgren <mats@mozilla.com>
Thu, 08 Jun 2017 12:48:32 +0200
changeset 411078 97735d7197e2004195d3689e332af6efe968673d
parent 411077 d1a431f894c29fe4ef5ebde3dc6431d1566307d2
child 411079 ccf7273933f03b7732450300ec4a7b91aed66716
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1371061
milestone55.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 1371061 - Optimize nsBaseHashtable::GetOrInsert() to only do a single hashtable lookup. r=froydnj MozReview-Commit-ID: 6muOorLplG1
xpcom/ds/nsBaseHashtable.h
--- a/xpcom/ds/nsBaseHashtable.h
+++ b/xpcom/ds/nsBaseHashtable.h
@@ -118,22 +118,17 @@ public:
 
   /**
    * Add key to the table if not already present, and return a reference to its
    * value.  If key is not already in the table then the value is default
    * constructed.
    */
   DataType& GetOrInsert(const KeyType& aKey)
   {
-    EntryType* ent = this->GetEntry(aKey);
-    if (ent) {
-      return ent->mData;
-    }
-
-    ent = this->PutEntry(aKey);
+    EntryType* ent = this->PutEntry(aKey);
     return ent->mData;
   }
 
   /**
    * put a new value for the associated key
    * @param aKey the key to put
    * @param aData the new data
    * @return always true, unless memory allocation failed