diff options
Diffstat (limited to '')
-rw-r--r-- | js/src/ds/OrderedHashTable.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/js/src/ds/OrderedHashTable.h b/js/src/ds/OrderedHashTable.h index 75c22bd123..9dd3e216d3 100644 --- a/js/src/ds/OrderedHashTable.h +++ b/js/src/ds/OrderedHashTable.h @@ -263,6 +263,12 @@ class OrderedHashTable { } *foundp = true; + return remove(e); + } + + bool remove(Data* e) { + MOZ_ASSERT(uint32_t(e - data) < dataCapacity); + liveCount--; Ops::makeEmpty(&e->element); @@ -277,6 +283,7 @@ class OrderedHashTable { return false; } } + return true; } @@ -967,6 +974,12 @@ class OrderedHashMap { bool remove(const Lookup& key, bool* foundp) { return impl.remove(key, foundp); } + // Remove an entry returned by get(). + bool remove(Entry* entry) { + static_assert(offsetof(typename Impl::Data, element) == 0); + auto* data = reinterpret_cast<typename Impl::Data*>(entry); + return impl.remove(data); + } [[nodiscard]] bool clear() { return impl.clear(); } template <typename K, typename V> |