Skip to content

Commit

Permalink
make progress end after last cell
Browse files Browse the repository at this point in the history
  • Loading branch information
janstarke committed Apr 17, 2024
1 parent b5ee855 commit aad73f9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/bin/hivescan/regtreebuilder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::{
cell::RefCell,
collections::{hash_map, HashMap},
rc::Rc,
cell::RefCell, cmp::max, collections::{hash_map, HashMap}, rc::Rc
};

use binread::BinReaderExt;
Expand Down Expand Up @@ -55,8 +53,10 @@ impl RegTreeBuilder {
};

let mut last_offset = Offset(0);
let mut last_cell_end = 0;
for cell in hive.hivebins().flat_map(|hivebin| hivebin.cells()) {
let my_offset = *cell.offset();
let my_size = cell.header().size();
let is_deleted = cell.header().is_deleted();
assert_ne!(last_offset, my_offset);
log::trace!("found new cell at offset 0x{:x}", my_offset.0);
Expand All @@ -65,7 +65,9 @@ impl RegTreeBuilder {
me.insert_nk(my_offset, nk, is_deleted);
}
last_offset = my_offset;
progress_callback(last_offset.0.into());

last_cell_end = max(last_cell_end, u64::from(last_offset.0) + u64::try_from(my_size).unwrap());
progress_callback(last_cell_end);
}
me
}
Expand Down

0 comments on commit aad73f9

Please sign in to comment.