Bug 1481138 - Remove the add() variant in HashTable and GCHashTable that uses a default value. r=luke
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 06 Aug 2018 09:10:05 +1000
changeset 430273 49d5dcbe36ff823980946cf45b9964a04efc2c1e
parent 430272 b217f71117484f9b45f504743381ce0557db5648
child 430274 01dcd8f80341ec39c949e364d5f46fd9c97963da
push id106116
push usernnethercote@mozilla.com
push dateTue, 07 Aug 2018 08:34:49 +0000
treeherdermozilla-inbound@09cd991472c9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1481138
milestone63.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 1481138 - Remove the add() variant in HashTable and GCHashTable that uses a default value. r=luke Because (a) it's kinda weird, and (b) only used in a single test, where it can be easily replaced with a vanilla add(). MozReview-Commit-ID: L4RoxFb7yGG
js/public/GCHashTable.h
js/src/jsapi-tests/testGCWeakCache.cpp
mfbt/HashTable.h
--- a/js/public/GCHashTable.h
+++ b/js/public/GCHashTable.h
@@ -551,21 +551,16 @@ class WeakCache<GCHashMap<Key, Value, Ha
     }
 
     void remove(const Lookup& l) {
         Ptr p = lookup(l);
         if (p)
             remove(p);
     }
 
-    template<typename KeyInput>
-    bool add(AddPtr& p, KeyInput&& k) {
-        return map.add(p, std::forward<KeyInput>(k));
-    }
-
     template<typename KeyInput, typename ValueInput>
     bool add(AddPtr& p, KeyInput&& k, ValueInput&& v) {
         return map.add(p, std::forward<KeyInput>(k), std::forward<ValueInput>(v));
     }
 
     template<typename KeyInput, typename ValueInput>
     bool relookupOrAdd(AddPtr& p, KeyInput&& k, ValueInput&& v) {
         return map.relookupOrAdd(p, std::forward<KeyInput>(k), std::forward<ValueInput>(v));
--- a/js/src/jsapi-tests/testGCWeakCache.cpp
+++ b/js/src/jsapi-tests/testGCWeakCache.cpp
@@ -644,17 +644,17 @@ TestReplaceDyingInMap()
     CHECK(!cache.has(6));
 
     auto ptr = cache.lookupForAdd(2);
     CHECK(!ptr);
     CHECK(cache.add(ptr, 2, value1));
 
     auto ptr2 = cache.lookupForAdd(3);
     CHECK(!ptr2);
-    CHECK(cache.add(ptr2, 3));
+    CHECK(cache.add(ptr2, 3, JS::Heap<JSObject*>()));
 
     auto ptr3 = cache.lookupForAdd(4);
     CHECK(!ptr3);
     CHECK(cache.relookupOrAdd(ptr3, 4, value1));
 
     CHECK(cache.put(5, value1));
     CHECK(cache.putNew(6, value1));
 
--- a/mfbt/HashTable.h
+++ b/mfbt/HashTable.h
@@ -344,23 +344,16 @@ public:
   // Add a key/value. Returns false on OOM.
   template<typename KeyInput, typename ValueInput>
   MOZ_MUST_USE bool add(AddPtr& aPtr, KeyInput&& aKey, ValueInput&& aValue)
   {
     return mImpl.add(
       aPtr, std::forward<KeyInput>(aKey), std::forward<ValueInput>(aValue));
   }
 
-  // Add a given key and a default value. Returns false on OOM.
-  template<typename KeyInput>
-  MOZ_MUST_USE bool add(AddPtr& aPtr, KeyInput&& aKey)
-  {
-    return mImpl.add(aPtr, std::forward<KeyInput>(aKey), Value());
-  }
-
   // See the comment above lookupForAdd() for details.
   template<typename KeyInput, typename ValueInput>
   MOZ_MUST_USE bool relookupOrAdd(AddPtr& aPtr,
                                   KeyInput&& aKey,
                                   ValueInput&& aValue)
   {
     return mImpl.relookupOrAdd(aPtr,
                                aKey,