From 54c12b76ed04e3aa6a04dc7e29faa202b8e52bae Mon Sep 17 00:00:00 2001 From: Thomas Queiroz Date: Tue, 6 Dec 2022 03:16:20 -0300 Subject: [PATCH] AK: Remove HashMap::ensure_capacity This is not perfect, since the constuctor can still fail. --- AK/HashMap.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/AK/HashMap.h b/AK/HashMap.h index dd959728afc..24f37b0d0ae 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -34,7 +34,7 @@ public: HashMap(std::initializer_list 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::hash(key), [&](auto& entry) { return Traits::equals(key, entry.key); }); } - void ensure_capacity(size_t capacity) { m_table.ensure_capacity(capacity); } ErrorOr try_ensure_capacity(size_t capacity) { return m_table.try_ensure_capacity(capacity); } Optional::ConstPeekType> get(K const& key) const