File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed
portable-simd/crates/core_simd/src Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -158,7 +158,7 @@ fn merge_tree_scale_factor(n: usize) -> u64 {
158
158
panic ! ( "Platform not supported" ) ;
159
159
}
160
160
161
- ( ( 1 << 62 ) + n as u64 - 1 ) / n as u64
161
+ ( 1u64 << 62 ) . div_ceil ( n as u64 )
162
162
}
163
163
164
164
// Note: merge_tree_depth output is < 64 when left < right as f*x and f*y must
@@ -182,7 +182,7 @@ fn sqrt_approx(n: usize) -> usize {
182
182
// Finally we note that the exponentiation / division can be done directly
183
183
// with shifts. We OR with 1 to avoid zero-checks in the integer log.
184
184
let ilog = ( n | 1 ) . ilog2 ( ) ;
185
- let shift = ( 1 + ilog) / 2 ;
185
+ let shift = ilog. div_ceil ( 2 ) ;
186
186
( ( 1 << shift) + ( n >> shift) ) / 2
187
187
}
188
188
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ impl<'a> Iterator for Chars<'a> {
102
102
// `(len + 3)` can't overflow, because we know that the `slice::Iter`
103
103
// belongs to a slice in memory which has a maximum length of
104
104
// `isize::MAX` (that's well below `usize::MAX`).
105
- ( ( len + 3 ) / 4 , Some ( len) )
105
+ ( len. div_ceil ( 4 ) , Some ( len) )
106
106
}
107
107
108
108
#[ inline]
@@ -1532,11 +1532,11 @@ impl<'a> Iterator for EncodeUtf16<'a> {
1532
1532
// belongs to a slice in memory which has a maximum length of
1533
1533
// `isize::MAX` (that's well below `usize::MAX`)
1534
1534
if self . extra == 0 {
1535
- ( ( len + 2 ) / 3 , Some ( len) )
1535
+ ( len. div_ceil ( 3 ) , Some ( len) )
1536
1536
} else {
1537
1537
// We're in the middle of a surrogate pair, so add the remaining
1538
1538
// surrogate to the bounds.
1539
- ( ( len + 2 ) / 3 + 1 , Some ( len + 1 ) )
1539
+ ( len. div_ceil ( 3 ) + 1 , Some ( len + 1 ) )
1540
1540
}
1541
1541
}
1542
1542
}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ pub struct LaneCount<const N: usize>;
8
8
9
9
impl < const N : usize > LaneCount < N > {
10
10
/// The number of bytes in a bitmask with this many lanes.
11
- pub const BITMASK_LEN : usize = ( N + 7 ) / 8 ;
11
+ pub const BITMASK_LEN : usize = N . div_ceil ( 8 ) ;
12
12
}
13
13
14
14
/// Statically guarantees that a lane count is marked as supported.
You can’t perform that action at this time.
0 commit comments