From 10b25d2a57702afe9a27b74bec92a0f28de45446 Mon Sep 17 00:00:00 2001 From: James Puleo Date: Mon, 24 Jan 2022 19:31:20 -0500 Subject: [PATCH] AK: Implement `HashTable::try_ensure_capacity`, as used in `HashMap` This was used in `HashMap::try_ensure_capacity`, but was missing from `HashTable`s implementation. No one had used `HashMap::try_ensure_capacity` before so it went unnoticed! --- AK/HashTable.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AK/HashTable.h b/AK/HashTable.h index fbe47a0cf7e..8ecf2958191 100644 --- a/AK/HashTable.h +++ b/AK/HashTable.h @@ -205,6 +205,12 @@ public: rehash(capacity * 2); } + ErrorOr try_ensure_capacity(size_t capacity) + { + VERIFY(capacity >= size()); + return try_rehash(capacity * 2); + } + [[nodiscard]] bool contains(T const& value) const { return find(value) != end();