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 {
158158 panic ! ( "Platform not supported" ) ;
159159 }
160160
161- ( ( 1 << 62 ) + n as u64 - 1 ) / n as u64
161+ ( 1u64 << 62 ) . div_ceil ( n as u64 )
162162}
163163
164164// 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 {
182182 // Finally we note that the exponentiation / division can be done directly
183183 // with shifts. We OR with 1 to avoid zero-checks in the integer log.
184184 let ilog = ( n | 1 ) . ilog2 ( ) ;
185- let shift = ( 1 + ilog) / 2 ;
185+ let shift = ilog. div_ceil ( 2 ) ;
186186 ( ( 1 << shift) + ( n >> shift) ) / 2
187187}
188188
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ impl<'a> Iterator for Chars<'a> {
102102 // `(len + 3)` can't overflow, because we know that the `slice::Iter`
103103 // belongs to a slice in memory which has a maximum length of
104104 // `isize::MAX` (that's well below `usize::MAX`).
105- ( ( len + 3 ) / 4 , Some ( len) )
105+ ( len. div_ceil ( 4 ) , Some ( len) )
106106 }
107107
108108 #[ inline]
@@ -1532,11 +1532,11 @@ impl<'a> Iterator for EncodeUtf16<'a> {
15321532 // belongs to a slice in memory which has a maximum length of
15331533 // `isize::MAX` (that's well below `usize::MAX`)
15341534 if self . extra == 0 {
1535- ( ( len + 2 ) / 3 , Some ( len) )
1535+ ( len. div_ceil ( 3 ) , Some ( len) )
15361536 } else {
15371537 // We're in the middle of a surrogate pair, so add the remaining
15381538 // surrogate to the bounds.
1539- ( ( len + 2 ) / 3 + 1 , Some ( len + 1 ) )
1539+ ( len. div_ceil ( 3 ) + 1 , Some ( len + 1 ) )
15401540 }
15411541 }
15421542}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ pub struct LaneCount<const N: usize>;
88
99impl < const N : usize > LaneCount < N > {
1010 /// 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 ) ;
1212}
1313
1414/// Statically guarantees that a lane count is marked as supported.
You can’t perform that action at this time.
0 commit comments