Skip to content
Snippets Groups Projects
Commit 56e66993 authored by James Francis's avatar James Francis Committed by Jeremy Soller
Browse files

Changed for_bytes method for BlockLevel.

parent ab371cff
No related branches found
No related tags found
No related merge requests found
......@@ -48,12 +48,13 @@ pub struct BlockLevel(pub(crate) usize);
impl BlockLevel {
pub(crate) fn for_bytes(bytes: u64) -> Self {
//TODO: optimize
let mut level = BlockLevel(0);
while level.bytes() < bytes {
level.0 += 1;
if bytes == 0 {
return BlockLevel(0);
}
level
let level = bytes.div_ceil(BLOCK_SIZE)
.next_power_of_two()
.trailing_zeros() as usize;
BlockLevel(level)
}
pub fn blocks(self) -> i64 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment