Skip to content

Commit c518f2d

Browse files
committedMar 14, 2019
Overwrite Cursor's Seek::stream_{len, position} for performance
1 parent 598a1b4 commit c518f2d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

Diff for: ‎src/libstd/io/cursor.rs

+8
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ impl<T> io::Seek for Cursor<T> where T: AsRef<[u8]> {
212212
"invalid seek to a negative or overflowing position"))
213213
}
214214
}
215+
216+
fn stream_len(&mut self) -> io::Result<u64> {
217+
Ok(self.inner.as_ref().len() as u64)
218+
}
219+
220+
fn stream_position(&mut self) -> io::Result<u64> {
221+
Ok(self.pos)
222+
}
215223
}
216224

217225
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)