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:
commit
99592fdfa1
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user