Skip to content

Commit 2fe7ddc

Browse files
sfacklerMark-Simulacrum
authored andcommitted
clean up control flow
1 parent 59b6b11 commit 2fe7ddc

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

library/std/src/io/mod.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ where
367367
{
368368
let start_len = buf.len();
369369
let mut g = Guard { len: buf.len(), buf };
370-
let ret;
371370
loop {
372371
if g.len == g.buf.len() {
373372
unsafe {
@@ -387,10 +386,7 @@ where
387386
}
388387

389388
match r.read(&mut g.buf[g.len..]) {
390-
Ok(0) => {
391-
ret = Ok(g.len - start_len);
392-
break;
393-
}
389+
Ok(0) => return Ok(g.len - start_len),
394390
Ok(n) => {
395391
// We can't let g.len overflow which would result in the vec shrinking when the function returns. In
396392
// particular, that could break read_to_string if the shortened buffer doesn't end on a UTF-8 boundary.
@@ -400,14 +396,9 @@ where
400396
g.len += n;
401397
}
402398
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
403-
Err(e) => {
404-
ret = Err(e);
405-
break;
406-
}
399+
Err(e) => return Err(e),
407400
}
408401
}
409-
410-
ret
411402
}
412403

413404
pub(crate) fn default_read_vectored<F>(read: F, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>

0 commit comments

Comments
 (0)