1
1
use std:: borrow:: Borrow ;
2
- use std:: collections:: hash_map:: RawEntryMut ;
3
2
use std:: hash:: { Hash , Hasher } ;
4
3
use std:: { iter, mem} ;
5
4
6
5
#[ cfg( parallel_compiler) ]
7
6
use either:: Either ;
7
+ use indexmap:: map:: RawEntryApiV1 ;
8
+ use indexmap:: map:: raw_entry_v1:: RawEntryMut ;
8
9
9
- use crate :: fx:: { FxHashMap , FxHasher } ;
10
+ use crate :: fx:: { FxHasher , FxIndexMap } ;
10
11
#[ cfg( parallel_compiler) ]
11
12
use crate :: sync:: { CacheAligned , is_dyn_thread_safe} ;
12
13
use crate :: sync:: { Lock , LockGuard , Mode } ;
@@ -159,15 +160,15 @@ pub fn shards() -> usize {
159
160
1
160
161
}
161
162
162
- pub type ShardedHashMap < K , V > = Sharded < FxHashMap < K , V > > ;
163
+ pub type ShardedIndexMap < K , V > = Sharded < FxIndexMap < K , V > > ;
163
164
164
- impl < K : Eq , V > ShardedHashMap < K , V > {
165
+ impl < K : Eq , V > ShardedIndexMap < K , V > {
165
166
pub fn len ( & self ) -> usize {
166
167
self . lock_shards ( ) . map ( |shard| shard. len ( ) ) . sum ( )
167
168
}
168
169
}
169
170
170
- impl < K : Eq + Hash + Copy > ShardedHashMap < K , ( ) > {
171
+ impl < K : Eq + Hash + Copy > ShardedIndexMap < K , ( ) > {
171
172
#[ inline]
172
173
pub fn intern_ref < Q : ?Sized > ( & self , value : & Q , make : impl FnOnce ( ) -> K ) -> K
173
174
where
@@ -176,7 +177,7 @@ impl<K: Eq + Hash + Copy> ShardedHashMap<K, ()> {
176
177
{
177
178
let hash = make_hash ( value) ;
178
179
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) ;
180
181
181
182
match entry {
182
183
RawEntryMut :: Occupied ( e) => * e. key ( ) ,
@@ -196,7 +197,7 @@ impl<K: Eq + Hash + Copy> ShardedHashMap<K, ()> {
196
197
{
197
198
let hash = make_hash ( & value) ;
198
199
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) ;
200
201
201
202
match entry {
202
203
RawEntryMut :: Occupied ( e) => * e. key ( ) ,
@@ -214,12 +215,12 @@ pub trait IntoPointer {
214
215
fn into_pointer ( & self ) -> * const ( ) ;
215
216
}
216
217
217
- impl < K : Eq + Hash + Copy + IntoPointer > ShardedHashMap < K , ( ) > {
218
+ impl < K : Eq + Hash + Copy + IntoPointer > ShardedIndexMap < K , ( ) > {
218
219
pub fn contains_pointer_to < T : Hash + IntoPointer > ( & self , value : & T ) -> bool {
219
220
let hash = make_hash ( & value) ;
220
221
let shard = self . lock_shard_by_hash ( hash) ;
221
222
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 ( )
223
224
}
224
225
}
225
226
0 commit comments