File tree Expand file tree Collapse file tree 1 file changed +1
-19
lines changed
compiler/rustc_data_structures/src Expand file tree Collapse file tree 1 file changed +1
-19
lines changed Original file line number Diff line number Diff line change 11use crate :: fx:: { FxHashMap , FxHasher } ;
22use crate :: sync:: { Lock , LockGuard } ;
3- use smallvec:: SmallVec ;
43use std:: borrow:: Borrow ;
54use std:: collections:: hash_map:: RawEntryMut ;
65use std:: hash:: { Hash , Hasher } ;
@@ -37,24 +36,7 @@ impl<T: Default> Default for Sharded<T> {
3736impl < T > Sharded < T > {
3837 #[ inline]
3938 pub fn new ( mut value : impl FnMut ( ) -> T ) -> Self {
40- // Create a vector of the values we want
41- let mut values: SmallVec < [ _ ; SHARDS ] > =
42- ( 0 ..SHARDS ) . map ( |_| CacheAligned ( Lock :: new ( value ( ) ) ) ) . collect ( ) ;
43-
44- // Create an uninitialized array
45- let mut shards: mem:: MaybeUninit < [ CacheAligned < Lock < T > > ; SHARDS ] > =
46- mem:: MaybeUninit :: uninit ( ) ;
47-
48- unsafe {
49- // Copy the values into our array
50- let first = shards. as_mut_ptr ( ) as * mut CacheAligned < Lock < T > > ;
51- values. as_ptr ( ) . copy_to_nonoverlapping ( first, SHARDS ) ;
52-
53- // Ignore the content of the vector
54- values. set_len ( 0 ) ;
55-
56- Sharded { shards : shards. assume_init ( ) }
57- }
39+ Sharded { shards : [ ( ) ; SHARDS ] . map ( |( ) | CacheAligned ( Lock :: new ( value ( ) ) ) ) }
5840 }
5941
6042 /// The shard is selected by hashing `val` with `FxHasher`.
You can’t perform that action at this time.
0 commit comments