This commit is contained in:
Aran85 2025-06-17 14:18:47 -07:00 committed by GitHub
commit a752ad3920
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -13,6 +13,8 @@ impl GroupId {
// 32bit chunk size + 24bit group + 8bit cluster
const SHIFT: u32 = 8;
pub const COUNT: u32 = (1 << Self::SHIFT);
pub const CLUSTER_MASK: u64 = (Self::COUNT - 1) as u64;
pub const GROUP_MASK: u64 = ((1u64 << 24) - 1) << Self::SHIFT;
pub const fn new(chunk_size: Size, cluster: u8, group: u32) -> Self {
Self(chunk_size.0 << 32 | (group << Self::SHIFT | cluster as u32) as u64)
@ -31,8 +33,7 @@ impl GroupId {
}
pub fn offset(&self) -> Size {
const MARKS: u64 = !(GroupId::COUNT - 1) as u64;
self.chunk_size() * (self.0 & MARKS)
self.chunk_size() * (self.0 & Self::GROUP_MASK)
}
pub fn size(&self) -> Size {

View File

@ -16,8 +16,7 @@ impl Position {
}
pub fn group_id(&self) -> GroupId {
const MARKS: u64 = (GroupId::COUNT - 1) as u64;
const CLEAN: u64 = !(MARKS | MARKS << 32);
const CLEAN: u64 = !(GroupId::CLUSTER_MASK | GroupId::CLUSTER_MASK << 32);
GroupId::from(self.0 & CLEAN | self.cluster() as u64)
}