From 7d2cfcab9d8291e412f41e43cdadf587d700d577 Mon Sep 17 00:00:00 2001 From: MichaƂ Kostrubiec Date: Tue, 25 Feb 2025 00:43:25 +0100 Subject: Changed interners to start with preallocated capacity --- compiler/rustc_data_structures/src/sharded.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'compiler/rustc_data_structures/src') diff --git a/compiler/rustc_data_structures/src/sharded.rs b/compiler/rustc_data_structures/src/sharded.rs index 65488c73d3c..5a53f8af5f8 100644 --- a/compiler/rustc_data_structures/src/sharded.rs +++ b/compiler/rustc_data_structures/src/sharded.rs @@ -143,6 +143,9 @@ pub fn shards() -> usize { pub type ShardedHashMap = Sharded>; impl ShardedHashMap { + pub fn with_capacity(cap: usize) -> Self { + Self::new(|| FxHashMap::with_capacity_and_hasher(cap, rustc_hash::FxBuildHasher::default())) + } pub fn len(&self) -> usize { self.lock_shards().map(|shard| shard.len()).sum() } -- cgit 1.4.1-3-g733a5