From 706202218700c989b760942170515c7f3757290b Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 27 Oct 2017 11:02:09 +0800 Subject: [PATCH] HashMap: Tolerate reserving for 0 elements Fixes #1652 --- src/hash_map.hh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hash_map.hh b/src/hash_map.hh index c9502aa4..94d20498 100644 --- a/src/hash_map.hh +++ b/src/hash_map.hh @@ -54,7 +54,9 @@ struct HashIndex constexpr void reserve(size_t count) { - kak_assert(count > 0); + if (count == 0) + return; + const size_t min_size = (size_t)(count / max_fill_rate) + 1; size_t new_size = m_entries.empty() ? 4 : m_entries.size(); while (new_size < min_size)