3
3
4
4
use std:: borrow:: Cow ;
5
5
use std:: cell:: RefCell ;
6
- use std:: collections:: HashMap ;
7
6
use std:: num:: NonZeroU64 ;
8
7
use std:: rc:: Rc ;
9
8
10
9
use rand:: rngs:: StdRng ;
11
10
11
+ use rustc_data_structures:: fx:: FxHashMap ;
12
12
use rustc:: mir;
13
13
use rustc:: ty:: {
14
14
self ,
15
15
layout:: { LayoutOf , Size } ,
16
16
Ty ,
17
17
} ;
18
18
use rustc_ast:: attr;
19
- use rustc_span:: { source_map:: Span , symbol:: sym} ;
19
+ use rustc_span:: { source_map:: Span , symbol:: { sym, Symbol } } ;
20
20
21
21
use crate :: * ;
22
22
@@ -75,7 +75,7 @@ pub struct MemoryExtra {
75
75
pub intptrcast : intptrcast:: MemoryExtra ,
76
76
77
77
/// Mapping extern static names to their canonical allocation.
78
- pub ( crate ) extern_statics : HashMap < & ' static str , AllocId > ,
78
+ pub ( crate ) extern_statics : FxHashMap < Symbol , AllocId > ,
79
79
80
80
/// The random number generator used for resolving non-determinism.
81
81
/// Needs to be queried by ptr_to_int, hence needs interior mutability.
@@ -92,7 +92,7 @@ impl MemoryExtra {
92
92
MemoryExtra {
93
93
stacked_borrows,
94
94
intptrcast : Default :: default ( ) ,
95
- extern_statics : HashMap :: default ( ) ,
95
+ extern_statics : FxHashMap :: default ( ) ,
96
96
rng : RefCell :: new ( rng) ,
97
97
}
98
98
}
@@ -111,7 +111,7 @@ impl MemoryExtra {
111
111
this. memory
112
112
. extra
113
113
. extern_statics
114
- . insert ( "__cxa_thread_atexit_impl" , place. ptr . assert_ptr ( ) . alloc_id )
114
+ . insert ( Symbol :: intern ( "__cxa_thread_atexit_impl" ) , place. ptr . assert_ptr ( ) . alloc_id )
115
115
. unwrap_none ( ) ;
116
116
}
117
117
_ => { } // No "extern statics" supported on this platform
@@ -310,11 +310,11 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
310
310
} ;
311
311
let attrs = tcx. get_attrs ( def_id) ;
312
312
let link_name = match attr:: first_attr_value_str_by_name ( & attrs, sym:: link_name) {
313
- Some ( name) => name. as_str ( ) ,
314
- None => tcx. item_name ( def_id) . as_str ( ) ,
313
+ Some ( name) => name,
314
+ None => tcx. item_name ( def_id) ,
315
315
} ;
316
316
// Check if we know this one.
317
- if let Some ( canonical_id) = mem. extra . extern_statics . get ( & * link_name) {
317
+ if let Some ( canonical_id) = mem. extra . extern_statics . get ( & link_name) {
318
318
trace ! ( "canonical_alloc_id: {:?} ({}) -> {:?}" , id, link_name, canonical_id) ;
319
319
* canonical_id
320
320
} else {
0 commit comments