diff options
| author | Michał Kostrubiec <fractalfirdev@gmail.com> | 2025-02-25 00:43:25 +0100 |
|---|---|---|
| committer | Michał Kostrubiec <fractalfirdev@gmail.com> | 2025-02-25 01:17:01 +0100 |
| commit | 7d2cfcab9d8291e412f41e43cdadf587d700d577 (patch) | |
| tree | 646fa81295ea1a4985dc5a4dbf3af2783350da52 /compiler/rustc_data_structures/src | |
| parent | 28b83ee59698ae069f5355b8e03f976406f410f5 (diff) | |
| download | rust-7d2cfcab9d8291e412f41e43cdadf587d700d577.tar.gz rust-7d2cfcab9d8291e412f41e43cdadf587d700d577.zip | |
Changed interners to start with preallocated capacity
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/sharded.rs | 3 |
1 files changed, 3 insertions, 0 deletions
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<K, V> = Sharded<FxHashMap<K, V>>; impl<K: Eq, V> ShardedHashMap<K, V> { + 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() } |
