X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Findexed_map.rs;h=39565f048c07a25f30a6749b5057a55a15278664;hb=bedc2c64fcfe5fa5f85ded630e9ed2eb3c3651eb;hp=bb17d3450ee5ccb7193ebecd00583603071ba435;hpb=b0bf50fa2493e5364511eb781db9772a06e140f9;p=rust-lightning diff --git a/lightning/src/util/indexed_map.rs b/lightning/src/util/indexed_map.rs index bb17d345..39565f04 100644 --- a/lightning/src/util/indexed_map.rs +++ b/lightning/src/util/indexed_map.rs @@ -39,6 +39,14 @@ impl IndexedMap { } } + /// Constructs a new, empty map with the given capacity pre-allocated + pub fn with_capacity(capacity: usize) -> Self { + Self { + map: HashMap::with_capacity(capacity), + keys: Vec::with_capacity(capacity), + } + } + #[inline(always)] /// Fetches the element with the given `key`, if one exists. pub fn get(&self, key: &K) -> Option<&V> {