diff options
| author | Lukas Kalbertodt <lukas.kalbertodt@gmail.com> | 2019-03-14 13:27:49 +0100 |
|---|---|---|
| committer | Lukas Kalbertodt <lukas.kalbertodt@gmail.com> | 2019-03-14 13:43:19 +0100 |
| commit | c518f2dd7040eca7591d3cacffe3646d8f54ac7c (patch) | |
| tree | f42c3ca9af683c3207a34eb0513f4c40013a6692 | |
| parent | 598a1b4dd1a6cc1bfe689a6931af9e6aa47134e1 (diff) | |
| download | rust-c518f2dd7040eca7591d3cacffe3646d8f54ac7c.tar.gz rust-c518f2dd7040eca7591d3cacffe3646d8f54ac7c.zip | |
Overwrite Cursor's `Seek::stream_{len, position}` for performance
| -rw-r--r-- | src/libstd/io/cursor.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 873da0898c7..247d45c3ec9 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -212,6 +212,14 @@ impl<T> io::Seek for Cursor<T> where T: AsRef<[u8]> { "invalid seek to a negative or overflowing position")) } } + + fn stream_len(&mut self) -> io::Result<u64> { + Ok(self.inner.as_ref().len() as u64) + } + + fn stream_position(&mut self) -> io::Result<u64> { + Ok(self.pos) + } } #[stable(feature = "rust1", since = "1.0.0")] |
