perf: optimize chunk_start for single-block indexing
Bypasses bitwise shift and mask operations when `block_bits == 0`, directly indexing `self.block_offsets[i]` instead. This eliminates unnecessary arithmetic overhead for single-block cases while preserving the original block-based offset calculation for larger block sizes.
This commit is contained in:
@@ -271,6 +271,9 @@ impl UnitigFileReader {
|
||||
fn chunk_start(&self, i: usize) -> usize {
|
||||
assert!(!self.block_offsets.is_empty(),
|
||||
"random access requires UnitigFileReader::open(); use open_sequential() for iteration only");
|
||||
if self.block_bits == 0 {
|
||||
return self.block_offsets[i] as usize;
|
||||
}
|
||||
let block = i >> self.block_bits;
|
||||
let rem = i & self.mask;
|
||||
let mut offset = self.block_offsets[block] as usize;
|
||||
|
||||
Reference in New Issue
Block a user