File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
compiler/rustc_data_structures/src Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -68,13 +68,22 @@ impl SlotIndex {
6868 // slots (see `slot_index_exhaustive` in tests).
6969 #[ inline]
7070 const fn from_index ( idx : u32 ) -> Self {
71- if idx < 4096 {
72- return SlotIndex { bucket_idx : 0 , entries : 4096 , index_in_bucket : idx as usize } ;
71+ const FIRST_BUCKET_SHIFT : usize = 12 ;
72+ if idx < ( 1 << FIRST_BUCKET_SHIFT ) {
73+ return SlotIndex {
74+ bucket_idx : 0 ,
75+ entries : 1 << FIRST_BUCKET_SHIFT ,
76+ index_in_bucket : idx as usize ,
77+ } ;
7378 }
7479 // SAFETY: We already ruled out idx 0, so `checked_ilog2` can't return `None`.
7580 let bucket = unsafe { idx. checked_ilog2 ( ) . unwrap_unchecked ( ) as usize } ;
7681 let entries = 1 << bucket;
77- SlotIndex { bucket_idx : bucket - 11 , entries, index_in_bucket : idx as usize - entries }
82+ SlotIndex {
83+ bucket_idx : bucket - FIRST_BUCKET_SHIFT + 1 ,
84+ entries,
85+ index_in_bucket : idx as usize - entries,
86+ }
7887 }
7988
8089 // SAFETY: Buckets must be managed solely by functions here (i.e., get/put on SlotIndex) and
You can’t perform that action at this time.
0 commit comments