Skip to content

Commit da902d8

Browse files
authored
Speed up seeking to the beginning of a stream. (#9)
1 parent 0d14027 commit da902d8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/reading.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,13 @@ impl<T :io::Read + io::Seek> PacketReader<T> {
929929
// Seek to the start of the file to get the starting boundary
930930
try!(self.rdr.seek(SeekFrom::Start(0)));
931931
let (mut begin_pos, mut begin_pg) = pg_read_match_serial!();
932+
933+
// If the goal is the beginning, we are done.
934+
if pos_goal == 0 {
935+
//println!("Seeking to the beginning of the stream - skipping bisect.");
936+
found!(begin_pos);
937+
}
938+
932939
// Seek to the end of the file to get the ending boundary
933940
// TODO the 200 KB is just a guessed number, any ideas
934941
// to improve it?

0 commit comments

Comments
 (0)