diff --git a/src/hash_map.hh b/src/hash_map.hh index 94d20498..e0f7a4e2 100644 --- a/src/hash_map.hh +++ b/src/hash_map.hh @@ -35,7 +35,7 @@ struct HashIndex size_t new_size = 4; while (new_size < min_size) new_size *= 2; - m_entries.resize(new_size, {}); + m_entries.resize(new_size); } using ContainerType = Container; @@ -44,7 +44,7 @@ struct HashIndex { kak_assert(new_size > m_entries.size()); ContainerType old_entries = std::move(m_entries); - m_entries.resize(new_size, {}); + m_entries.resize(new_size); for (auto& entry : old_entries) { if (entry.index >= 0) diff --git a/src/meta.hh b/src/meta.hh index 110ad3b3..ce29a758 100644 --- a/src/meta.hh +++ b/src/meta.hh @@ -57,17 +57,14 @@ struct ConstexprVector constexpr bool empty() const { return m_size == 0; } constexpr size_t size() const { return m_size; } - constexpr void resize(size_t n, const T& val) + constexpr void resize(size_t n, const T& val = {}) { if (n >= capacity) throw "capacity exceeded"; - if (n > m_size) - { - for (int i = n; i < m_size; ++i) - m_data[i] = val; - } + for (int i = m_size; i < n; ++i) + m_data[i] = val; m_size = n; - kak_assert(this->size() == m_size); + kak_assert(this->size() == m_size); // check for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79520 } constexpr T& operator[](size_t i) { return m_data[i]; }