Skip to content
Snippets Groups Projects
Commit d8950b52 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Merge branch 'change_blocklevel_calc' into 'master'

Changed for_bytes method for BlockLevel.

See merge request redox-os/redoxfs!79
parents ab371cff 56e66993
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