Skip to content

Commit 6c236b8

Browse files
committed
Remove an outdated assertion
1 parent abbde8b commit 6c236b8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/util/heap/chunk_map.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ impl Chunk {
5252
pub struct ChunkState(u8);
5353

5454
impl ChunkState {
55+
const ALLOC_BIT_MASK: u8 = 0x80;
56+
const SPACE_INDEX_MASK: u8 = 0x0F;
57+
5558
/// Create a new ChunkState that represents being allocated in the given space
5659
pub fn allocated(space_index: usize) -> ChunkState {
5760
debug_assert!(space_index < crate::util::heap::layout::heap_parameters::MAX_SPACES);
5861
let mut encode = space_index as u8;
59-
encode |= 0x80;
62+
encode |= Self::ALLOC_BIT_MASK;
6063
ChunkState(encode)
6164
}
6265
/// Create a new ChunkState that represents being free in the given space
@@ -66,16 +69,15 @@ impl ChunkState {
6669
}
6770
/// Is the chunk free?
6871
pub fn is_free(&self) -> bool {
69-
self.0 & 0x80 == 0
72+
self.0 & Self::ALLOC_BIT_MASK == 0
7073
}
7174
/// Is the chunk allocated?
7275
pub fn is_allocated(&self) -> bool {
7376
!self.is_free()
7477
}
7578
/// Get the space index of the chunk
7679
pub fn get_space_index(&self) -> usize {
77-
debug_assert!(self.is_allocated());
78-
let index = (self.0 & 0x0F) as usize;
80+
let index = (self.0 & Self::SPACE_INDEX_MASK) as usize;
7981
debug_assert!(index < crate::util::heap::layout::heap_parameters::MAX_SPACES);
8082
index
8183
}

0 commit comments

Comments
 (0)