File tree 2 files changed +16
-4
lines changed
src/tools/unicode-table-generator/src
2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,10 @@ unsafe fn skip_search<const SOR: usize, const OFFSETS: usize>(
94
94
// correct location cannot be past it, so `Err(idx) => idx != length` either.
95
95
//
96
96
// This means that we can avoid bounds checking for the accesses below, too.
97
- unsafe { crate :: hint:: assert_unchecked ( last_idx < SOR ) } ;
97
+ //
98
+ // We need to use `intrinsics::assume` since the `panic_nounwind` contained
99
+ // in `hint::assert_unchecked` may not be optimized out.
100
+ unsafe { crate :: intrinsics:: assume ( last_idx < SOR ) } ;
98
101
99
102
let mut offset_idx = short_offset_runs[ last_idx] . start_index ( ) ;
100
103
let length = if let Some ( next) = short_offset_runs. get ( last_idx + 1 ) {
@@ -112,7 +115,10 @@ unsafe fn skip_search<const SOR: usize, const OFFSETS: usize>(
112
115
// SAFETY: It is guaranteed that `length <= OFFSETS - offset_idx`,
113
116
// so it follows that `length - 1 + offset_idx < OFFSETS`, therefore
114
117
// `offset_idx < OFFSETS` is always true in this loop.
115
- unsafe { crate :: hint:: assert_unchecked ( offset_idx < OFFSETS ) } ;
118
+ //
119
+ // We need to use `intrinsics::assume` since the `panic_nounwind` contained
120
+ // in `hint::assert_unchecked` may not be optimized out.
121
+ unsafe { crate :: intrinsics:: assume ( offset_idx < OFFSETS ) } ;
116
122
let offset = offsets[ offset_idx] ;
117
123
prefix_sum += offset as u32 ;
118
124
if prefix_sum > total {
Original file line number Diff line number Diff line change @@ -92,7 +92,10 @@ unsafe fn skip_search<const SOR: usize, const OFFSETS: usize>(
92
92
// correct location cannot be past it, so `Err(idx) => idx != length` either.
93
93
//
94
94
// This means that we can avoid bounds checking for the accesses below, too.
95
- unsafe { crate :: hint:: assert_unchecked ( last_idx < SOR ) } ;
95
+ //
96
+ // We need to use `intrinsics::assume` since the `panic_nounwind` contained
97
+ // in `hint::assert_unchecked` may not be optimized out.
98
+ unsafe { crate :: intrinsics:: assume ( last_idx < SOR ) } ;
96
99
97
100
let mut offset_idx = short_offset_runs[ last_idx] . start_index ( ) ;
98
101
let length = if let Some ( next) = short_offset_runs. get ( last_idx + 1 ) {
@@ -110,7 +113,10 @@ unsafe fn skip_search<const SOR: usize, const OFFSETS: usize>(
110
113
// SAFETY: It is guaranteed that `length <= OFFSETS - offset_idx`,
111
114
// so it follows that `length - 1 + offset_idx < OFFSETS`, therefore
112
115
// `offset_idx < OFFSETS` is always true in this loop.
113
- unsafe { crate :: hint:: assert_unchecked ( offset_idx < OFFSETS ) } ;
116
+ //
117
+ // We need to use `intrinsics::assume` since the `panic_nounwind` contained
118
+ // in `hint::assert_unchecked` may not be optimized out.
119
+ unsafe { crate :: intrinsics:: assume ( offset_idx < OFFSETS ) } ;
114
120
let offset = offsets[ offset_idx] ;
115
121
prefix_sum += offset as u32 ;
116
122
if prefix_sum > total {
You can’t perform that action at this time.
0 commit comments