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
--- 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,