Skip to content

Commit 83ccdf3

Browse files
author
José Molina
committed
Improve reads
1 parent 53fcca5 commit 83ccdf3

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/common.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,9 @@ impl ChunkedFile {
4242
impl Read for ChunkedFile {
4343
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
4444
let mut currently_read = 0;
45-
let mut index = match self.chunks.iter().position(|(_, chunk)| {
45+
let mut index = self.chunks.iter().position(|(_, chunk)| {
4646
chunk.offset >= self.position && chunk.offset + chunk.size < self.position
47-
}) {
48-
None => return Err(ErrorKind::UnexpectedEof.into()),
49-
Some(i) => i,
50-
};
47+
}).unwrap_or_else(|| usize::MAX);
5148
while currently_read < buf.len() && index < self.chunks.len() {
5249
let (path, chunk) = &self.chunks[index];
5350
let chunk_position = self.position - chunk.offset;

0 commit comments

Comments
 (0)