11use std:: borrow:: Borrow ;
2- use std:: collections:: hash_map:: RawEntryMut ;
32use std:: hash:: { Hash , Hasher } ;
43use std:: { iter, mem} ;
54
65#[ cfg( parallel_compiler) ]
76use either:: Either ;
7+ use indexmap:: map:: RawEntryApiV1 ;
8+ use indexmap:: map:: raw_entry_v1:: RawEntryMut ;
89
9- use crate :: fx:: { FxHashMap , FxHasher } ;
10+ use crate :: fx:: { FxHasher , FxIndexMap } ;
1011#[ cfg( parallel_compiler) ]
1112use crate :: sync:: { CacheAligned , is_dyn_thread_safe} ;
1213use crate :: sync:: { Lock , LockGuard , Mode } ;
@@ -159,15 +160,15 @@ pub fn shards() -> usize {
159160 1
160161}
161162
162- pub type ShardedHashMap < K , V > = Sharded < FxHashMap < K , V > > ;
163+ pub type ShardedIndexMap < K , V > = Sharded < FxIndexMap < K , V > > ;
163164
164- impl < K : Eq , V > ShardedHashMap < K , V > {
165+ impl < K : Eq , V > ShardedIndexMap < K , V > {
165166 pub fn len ( & self ) -> usize {
166167 self . lock_shards ( ) . map ( |shard| shard. len ( ) ) . sum ( )
167168 }
168169}
169170
170- impl < K : Eq + Hash + Copy > ShardedHashMap < K , ( ) > {
171+ impl < K : Eq + Hash + Copy > ShardedIndexMap < K , ( ) > {
171172 #[ inline]
172173 pub fn intern_ref < Q : ?Sized > ( & self , value : & Q , make : impl FnOnce ( ) -> K ) -> K
173174 where
@@ -176,7 +177,7 @@ impl<K: Eq + Hash + Copy> ShardedHashMap<K, ()> {
176177 {
177178 let hash = make_hash ( value) ;
178179 let mut shard = self . lock_shard_by_hash ( hash) ;
179- let entry = shard. raw_entry_mut ( ) . from_key_hashed_nocheck ( hash, value) ;
180+ let entry = shard. raw_entry_mut_v1 ( ) . from_key_hashed_nocheck ( hash, value) ;
180181
181182 match entry {
182183 RawEntryMut :: Occupied ( e) => * e. key ( ) ,
@@ -196,7 +197,7 @@ impl<K: Eq + Hash + Copy> ShardedHashMap<K, ()> {
196197 {
197198 let hash = make_hash ( & value) ;
198199 let mut shard = self . lock_shard_by_hash ( hash) ;
199- let entry = shard. raw_entry_mut ( ) . from_key_hashed_nocheck ( hash, & value) ;
200+ let entry = shard. raw_entry_mut_v1 ( ) . from_key_hashed_nocheck ( hash, & value) ;
200201
201202 match entry {
202203 RawEntryMut :: Occupied ( e) => * e. key ( ) ,
@@ -214,12 +215,12 @@ pub trait IntoPointer {
214215 fn into_pointer ( & self ) -> * const ( ) ;
215216}
216217
217- impl < K : Eq + Hash + Copy + IntoPointer > ShardedHashMap < K , ( ) > {
218+ impl < K : Eq + Hash + Copy + IntoPointer > ShardedIndexMap < K , ( ) > {
218219 pub fn contains_pointer_to < T : Hash + IntoPointer > ( & self , value : & T ) -> bool {
219220 let hash = make_hash ( & value) ;
220221 let shard = self . lock_shard_by_hash ( hash) ;
221222 let value = value. into_pointer ( ) ;
222- shard. raw_entry ( ) . from_hash ( hash, |entry| entry. into_pointer ( ) == value) . is_some ( )
223+ shard. raw_entry_v1 ( ) . from_hash ( hash, |entry| entry. into_pointer ( ) == value) . is_some ( )
223224 }
224225}
225226
0 commit comments