From 1a74895680bd7dc6af50c73f2191c10b46b54a75 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 3 Apr 2022 18:03:24 +0430 Subject: [PATCH] AK: Return Optional for HashMap::get() const While the previous implementation always copied the object, returning a non-const reference to a const object is not valid. --- AK/HashMap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AK/HashMap.h b/AK/HashMap.h index 4590f932d0..50abecd638 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -127,7 +127,7 @@ public: 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::PeekType> get(const K& key) const requires(!IsPointer::PeekType>) + Optional::ConstPeekType> get(const K& key) const requires(!IsPointer::PeekType>) { auto it = find(key); if (it == end())