Use HashMap::with_capacity instead of new+reserve
This commit is contained in:
parent
2b6e344bc4
commit
fb0654e263
1 changed files with 1 additions and 2 deletions
|
@ -4,8 +4,7 @@ macro_rules! hashmap {
|
||||||
(@count $($expr:expr),*) => (<[()]>::len(&[$(hashmap!(@discard $expr)),*]));
|
(@count $($expr:expr),*) => (<[()]>::len(&[$(hashmap!(@discard $expr)),*]));
|
||||||
($($($key:expr => $expr:expr),+ $(,)?)?) => {{
|
($($($key:expr => $expr:expr),+ $(,)?)?) => {{
|
||||||
let cap = hashmap!(@count $($($key),*)?);
|
let cap = hashmap!(@count $($($key),*)?);
|
||||||
let mut map = ::std::collections::HashMap::new();
|
let mut map = ::std::collections::HashMap::with_capacity(cap);
|
||||||
map.reserve(cap);
|
|
||||||
$($(map.insert($key, $expr);)*)?
|
$($(map.insert($key, $expr);)*)?
|
||||||
map
|
map
|
||||||
}};
|
}};
|
||||||
|
|
Loading…
Reference in a new issue