Skip to content

Commit

Permalink
remove search_range from find_border
Browse files Browse the repository at this point in the history
  • Loading branch information
Piletskii-Oleg committed May 1, 2024
1 parent a197a53 commit b06d7f3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/rabin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct RabinChunker<'a> {
params: ChunkerParams, // chunker parameters
pos: usize,
chunk_start: usize,
len: usize
len: usize,
}

/// Pre-calculated chunker parameters
Expand All @@ -55,9 +55,7 @@ impl<'a> RabinChunker<'a> {
}

fn find_border(&mut self) -> Option<usize> {
let search_range = self.pos..self.len;

if search_range.is_empty() {
if self.pos == self.len {
return None;
}

Expand Down Expand Up @@ -102,10 +100,10 @@ impl<'a> Iterator for RabinChunker<'a> {
type Item = Chunk;

fn next(&mut self) -> Option<Self::Item> {
self.chunk_start = self.pos;
let start = self.pos;

if let Some(length) = self.find_border() {
Some(Chunk::new(self.chunk_start, length))
Some(Chunk::new(start, length))
} else {
None
}
Expand Down

0 comments on commit b06d7f3

Please sign in to comment.