@@ -17,6 +17,7 @@ use ty::{self, TyCtxt, fast_reject};
17
17
18
18
use std:: cmp:: Ord ;
19
19
use std:: hash as std_hash;
20
+ use std:: cell:: RefCell ;
20
21
use std:: collections:: HashMap ;
21
22
22
23
use syntax:: ast;
@@ -30,6 +31,10 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHashingContextProvi
30
31
StableHasher , StableHasherResult ,
31
32
ToStableHashKey } ;
32
33
use rustc_data_structures:: accumulate_vec:: AccumulateVec ;
34
+ use rustc_data_structures:: fx:: FxHashSet ;
35
+
36
+ thread_local ! ( static IGNORED_ATTR_NAMES : RefCell <FxHashSet <Symbol >> =
37
+ RefCell :: new( FxHashSet ( ) ) ) ;
33
38
34
39
/// This is the context state available during incr. comp. hashing. It contains
35
40
/// enough information to transform DefIds and HirIds into stable DefPaths (i.e.
@@ -41,8 +46,6 @@ pub struct StableHashingContext<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
41
46
hash_bodies : bool ,
42
47
overflow_checks_enabled : bool ,
43
48
node_id_hashing_mode : NodeIdHashingMode ,
44
- // A sorted array of symbol keys for fast lookup.
45
- ignored_attr_names : Vec < Symbol > ,
46
49
47
50
// Very often, we are hashing something that does not need the
48
51
// CachingCodemapView, so we initialize it lazily.
@@ -62,12 +65,14 @@ impl<'a, 'gcx, 'tcx> StableHashingContext<'a, 'gcx, 'tcx> {
62
65
let hash_spans_initial = tcx. sess . opts . debuginfo != NoDebugInfo ;
63
66
let check_overflow_initial = tcx. sess . overflow_checks ( ) ;
64
67
65
- let mut ignored_attr_names: Vec < _ > = ich:: IGNORED_ATTRIBUTES
66
- . iter ( )
67
- . map ( |& s| Symbol :: intern ( s) )
68
- . collect ( ) ;
69
-
70
- ignored_attr_names. sort ( ) ;
68
+ debug_assert ! ( ich:: IGNORED_ATTRIBUTES . len( ) > 0 ) ;
69
+ IGNORED_ATTR_NAMES . with ( |names| {
70
+ let mut names = names. borrow_mut ( ) ;
71
+ if names. is_empty ( ) {
72
+ names. extend ( ich:: IGNORED_ATTRIBUTES . iter ( )
73
+ . map ( |& s| Symbol :: intern ( s) ) ) ;
74
+ }
75
+ } ) ;
71
76
72
77
StableHashingContext {
73
78
tcx,
@@ -77,7 +82,6 @@ impl<'a, 'gcx, 'tcx> StableHashingContext<'a, 'gcx, 'tcx> {
77
82
hash_bodies : true ,
78
83
overflow_checks_enabled : check_overflow_initial,
79
84
node_id_hashing_mode : NodeIdHashingMode :: HashDefPath ,
80
- ignored_attr_names,
81
85
}
82
86
}
83
87
@@ -151,7 +155,9 @@ impl<'a, 'gcx, 'tcx> StableHashingContext<'a, 'gcx, 'tcx> {
151
155
152
156
#[ inline]
153
157
pub fn is_ignored_attr ( & self , name : Symbol ) -> bool {
154
- self . ignored_attr_names . binary_search ( & name) . is_ok ( )
158
+ IGNORED_ATTR_NAMES . with ( |names| {
159
+ names. borrow ( ) . contains ( & name)
160
+ } )
155
161
}
156
162
157
163
pub fn hash_hir_item_like < F : FnOnce ( & mut Self ) > ( & mut self ,
0 commit comments