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 b4ca2d8 commit aa27dd2
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,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| {
let pos = if self.hold_max {
self.progress.position().max(pos)
} else {
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
};
self.progress.set_position(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 aa27dd2

Please sign in to comment.