From fb0654e263aafd12b3ff69680d530de2ef82cd51 Mon Sep 17 00:00:00 2001 From: Avery Winters Date: Mon, 15 Jan 2024 11:21:55 -0600 Subject: [PATCH] Use HashMap::with_capacity instead of new+reserve --- rust/macros/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rust/macros/src/lib.rs b/rust/macros/src/lib.rs index 135c24d..f117487 100644 --- a/rust/macros/src/lib.rs +++ b/rust/macros/src/lib.rs @@ -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 }};