Skip to content

Commit

Permalink
Inline Bytes::next and Bytes::size_hint.
Browse files Browse the repository at this point in the history
This greatly increases its speed.
  • Loading branch information
nnethercote committed Oct 15, 2023
1 parent 64368d0 commit 4d68108
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -2789,6 +2790,7 @@ impl<R: Read> Iterator for Bytes<R> {
}
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
SizeHint::size_hint(&self.inner)
}
Expand Down

0 comments on commit 4d68108

Please sign in to comment.