Skip to content

clippy fix: use div_ceil #468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions crates/core_simd/src/lane_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct LaneCount<const N: usize>;

impl<const N: usize> LaneCount<N> {
/// The number of bytes in a bitmask with this many lanes.
pub const BITMASK_LEN: usize = (N + 7) / 8;
pub const BITMASK_LEN: usize = N.div_ceil(8);
}

/// Statically guarantees that a lane count is marked as supported.
Expand All @@ -31,13 +31,12 @@ macro_rules! supported_lane_count {
($($lanes:literal),+) => {
$(
impl SupportedLaneCount for LaneCount<$lanes> {
type BitMask = [u8; ($lanes + 7) / 8];
const EMPTY_BIT_MASK: Self::BitMask = [0; ($lanes + 7) / 8];
type BitMask = [u8; Self::BITMASK_LEN];
const EMPTY_BIT_MASK: Self::BitMask = [0; Self::BITMASK_LEN];
const FULL_BIT_MASK: Self::BitMask = {
const LEN: usize = ($lanes + 7) / 8;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, it didn't work in this scope?

Copy link
Member Author

@hkBst hkBst Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it has the right scope to be used for BitMask, but looking at this code again, I'm wondering why I didn't reuse the LaneCount::BITMASK_LEN...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now done, seems much better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

let mut array = [!0u8; LEN];
let mut array = [!0u8; Self::BITMASK_LEN];
if $lanes % 8 > 0 {
array[LEN - 1] = (!0) >> (8 - $lanes % 8);
array[Self::BITMASK_LEN - 1] = (!0) >> (8 - $lanes % 8);
}
array
};
Expand Down