AK: Remove HashMap::ensure_capacity

This is not perfect, since the constuctor can still fail.
This commit is contained in:
Thomas Queiroz 2022-12-06 03:16:20 -03:00 committed by Andreas Kling
parent 0380ff30aa
commit 54c12b76ed
Notes: sideshowbarker 2024-07-17 03:28:09 +09:00

View File

@ -34,7 +34,7 @@ public:
HashMap(std::initializer_list<Entry> list)
{
ensure_capacity(list.size());
MUST(try_ensure_capacity(list.size()));
for (auto& item : list)
set(item.key, item.value);
}
@ -124,7 +124,6 @@ public:
return m_table.find(Traits<Key>::hash(key), [&](auto& entry) { return Traits<K>::equals(key, entry.key); });
}
void ensure_capacity(size_t capacity) { m_table.ensure_capacity(capacity); }
ErrorOr<void> try_ensure_capacity(size_t capacity) { return m_table.try_ensure_capacity(capacity); }
Optional<typename Traits<V>::ConstPeekType> get(K const& key) const