diff options
| author | bors <bors@rust-lang.org> | 2023-10-16 04:05:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-16 04:05:32 +0000 |
| commit | 99592fdfa14ecbcf0f42f97d2cfa5ef8f3c289fe (patch) | |
| tree | 9c72047b5d3e42418a4223b310f5db63006e7fdc /library/std | |
| parent | 58352c06497ac1cc8f7c49d30d6df967134efbaf (diff) | |
| parent | 4d6810844e1b7a10af1da44d3217a66005866234 (diff) | |
| download | rust-99592fdfa14ecbcf0f42f97d2cfa5ef8f3c289fe.tar.gz rust-99592fdfa14ecbcf0f42f97d2cfa5ef8f3c289fe.zip | |
Auto merge of #116775 - nnethercote:inline-Bytes-next, r=the8472
Inline `Bytes::next` and `Bytes::size_hint`. This greatly increases its speed. On one small test program using `Bytes::next` to iterate over a large file, execution time dropped from ~330ms to ~220ms. r? `@the8472`
Diffstat (limited to 'library/std')
| -rw-r--r-- | library/std/src/io/mod.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index e6431abcf82..c0a72948112 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -2777,6 +2777,7 @@ pub struct Bytes<R> { impl<R: Read> Iterator for Bytes<R> { type Item = Result<u8>; + #[inline] fn next(&mut self) -> Option<Result<u8>> { let mut byte = 0; loop { @@ -2789,6 +2790,7 @@ impl<R: Read> Iterator for Bytes<R> { } } + #[inline] fn size_hint(&self) -> (usize, Option<usize>) { SizeHint::size_hint(&self.inner) } |
