diff --git a/vlib/builtin/map.v b/vlib/builtin/map.v index 7b96d124af..71ad5275af 100644 --- a/vlib/builtin/map.v +++ b/vlib/builtin/map.v @@ -425,6 +425,11 @@ fn (mut m map) expand() { // the max_load_factor in an operation. fn (mut m map) rehash() { meta_bytes := sizeof(u32) * (m.even_index + 2 + m.extra_metas) + m.reserve(meta_bytes) +} + +// reserve memory for the map meta data +pub fn (mut m map) reserve(meta_bytes u32) { unsafe { // TODO: use realloc_data here too x := v_realloc(&u8(m.metas), int(meta_bytes))