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)),*]));
|
||||
($($($key:expr => $expr:expr),+ $(,)?)?) => {{
|
||||
let cap = hashmap!(@count $($($key),*)?);
|
||||
let mut map = ::std::collections::HashMap::new();
|
||||
map.reserve(cap);
|
||||
let mut map = ::std::collections::HashMap::with_capacity(cap);
|
||||
$($(map.insert($key, $expr);)*)?
|
||||
map
|
||||
}};
|
||||
|
|
Loading…
Reference in a new issue