mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: add a map.reserve/1 method (#17052)
This commit is contained in:
parent
3a9355d898
commit
6d223b9a26
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user