Skip to content

Commit 251143b

Browse files
authored
Merge pull request #561 from cgwalters/translate-hash-size
translate: Pre-allocate Rust hashmap at correct size
2 parents c010aaa + f5e18d5 commit 251143b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

glib/src/translate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2202,7 +2202,7 @@ impl FromGlibPtrContainer<*const c_char, *mut ffi::GHashTable> for HashMap<Strin
22022202
&mut *(hash_map as *mut HashMap<String, String>);
22032203
hash_map.insert(key, value);
22042204
}
2205-
let mut map = HashMap::new();
2205+
let mut map = HashMap::with_capacity(ffi::g_hash_table_size(ptr) as usize);
22062206
ffi::g_hash_table_foreach(
22072207
ptr,
22082208
Some(read_string_hash_table),

0 commit comments

Comments
 (0)