@@ -77,11 +77,7 @@ impl Initializer {
77
77
}
78
78
79
79
/// This global variable is a cache of the features supported by the CPU.
80
- #[ cfg( target_pointer_width = "64" ) ]
81
- static CACHE : [ Cache ; 1 ] = [ Cache :: uninitialized ( ) ] ;
82
-
83
- /// This global variable is a cache of the features supported by the CPU.
84
- #[ cfg( target_pointer_width = "32" ) ]
80
+ // Note: on x64, we only use the first slot
85
81
static CACHE : [ Cache ; 2 ] = [ Cache :: uninitialized ( ) , Cache :: uninitialized ( ) ] ;
86
82
87
83
/// Feature cache with capacity for `usize::max_value() - 1` features.
@@ -145,10 +141,7 @@ cfg_if::cfg_if! {
145
141
#[ inline]
146
142
fn do_initialize ( value : Initializer ) {
147
143
CACHE [ 0 ] . initialize ( ( value. 0 ) as usize & Cache :: MASK ) ;
148
- #[ cfg( target_pointer_width = "32" ) ]
149
- {
150
- CACHE [ 1 ] . initialize ( ( value. 0 >> Cache :: CAPACITY ) as usize & Cache :: MASK ) ;
151
- }
144
+ CACHE [ 1 ] . initialize ( ( value. 0 >> Cache :: CAPACITY ) as usize & Cache :: MASK ) ;
152
145
}
153
146
154
147
/// Tests the `bit` of the storage. If the storage has not been initialized,
@@ -168,18 +161,14 @@ pub(crate) fn test<F>(bit: u32, f: F) -> bool
168
161
where
169
162
F : FnOnce ( ) -> Initializer ,
170
163
{
171
- #[ cfg( target_pointer_width = "32" ) ]
172
- {
173
- if bit >= Cache :: CAPACITY {
174
- if CACHE [ 1 ] . is_uninitialized ( ) {
175
- initialize ( f ( ) )
176
- }
177
- return CACHE [ 1 ] . test ( bit - Cache :: CAPACITY ) ;
178
- }
179
- }
164
+ let ( bit, idx) = if bit < Cache :: CAPACITY {
165
+ ( bit, 0 )
166
+ } else {
167
+ ( bit - Cache :: CAPACITY , 1 )
168
+ } ;
180
169
181
- if CACHE [ 0 ] . is_uninitialized ( ) {
170
+ if CACHE [ idx ] . is_uninitialized ( ) {
182
171
initialize ( f ( ) )
183
172
}
184
- CACHE [ 0 ] . test ( bit)
173
+ CACHE [ idx ] . test ( bit)
185
174
}
0 commit comments