Skip to content
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
13 changes: 6 additions & 7 deletions dc/s2n-quic-dc/src/task/waker/set/bitset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

use core::fmt;

const SLOT_BYTES: usize = core::mem::size_of::<usize>();
const SLOT_BITS: usize = SLOT_BYTES * 8;
const PER_SLOT: usize = core::mem::size_of::<usize>() * 8;

#[derive(Clone, Default)]
pub struct BitSet {
Expand Down Expand Up @@ -75,8 +74,8 @@ impl BitSet {

#[inline(always)]
fn index_mask(id: usize) -> (usize, usize) {
let index = id / SLOT_BYTES;
let mask = 1 << (id % SLOT_BYTES);
let index = id / PER_SLOT;
let mask = 1 << (id % PER_SLOT);
(index, mask)
}
}
Expand Down Expand Up @@ -116,17 +115,17 @@ impl<S: Slots> Iterator for Iter<S> {
let trailing = (slot >> self.shift).trailing_zeros() as usize;

// no more 1s so go to the next slot
if trailing == SLOT_BITS {
if trailing == PER_SLOT {
self.next_index(true);
continue;
}

let shift = self.shift + trailing;
let id = self.index * SLOT_BYTES + shift;
let id = self.index * PER_SLOT + shift;
let next_shift = shift + 1;

// check if the next shift overflows into the next index
if next_shift == SLOT_BITS {
if next_shift == PER_SLOT {
self.next_index(true);
} else {
self.shift = next_shift;
Expand Down
Loading