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`
This commit is contained in:
bors 2023-10-16 04:05:32 +00:00
commit 99592fdfa1

View File

@ -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)
}