Skip to content

Commit

Permalink
don't switch to heuristic mode for noop-seeks
Browse files Browse the repository at this point in the history
these regularely happen to find the current position in the file
  • Loading branch information
djugei committed Feb 5, 2025
1 parent a4a2579 commit d0715e4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,14 @@ impl<W: io::Write> io::Write for ProgressBarIter<W> {

impl<S: io::Seek> io::Seek for ProgressBarIter<S> {
fn seek(&mut self, f: io::SeekFrom) -> io::Result<u64> {
self.it.seek(f).map(|pos| {
self.progress.set_position(self.hold_max.update_seek(pos));
pos
})
if let io::SeekFrom::Current(0) = f {
self.it.seek(f)
} else {
self.it.seek(f).map(|pos| {
self.progress.set_position(self.hold_max.update_seek(pos));
pos
})
}
}
// Pass this through to preserve optimizations that the inner I/O object may use here
// Also avoid sending a set_position update when the position hasn't changed
Expand Down

0 comments on commit d0715e4

Please sign in to comment.