Skip to content

Commit a9ef798

Browse files
committed
clean up control flow
1 parent ebe402d commit a9ef798

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
@@ -366,7 +366,6 @@ where
366366
{
367367
let start_len = buf.len();
368368
let mut g = Guard { len: buf.len(), buf };
369-
let ret;
370369
loop {
371370
if g.len == g.buf.len() {
372371
unsafe {
@@ -386,10 +385,7 @@ where
386385
}
387386

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

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

0 commit comments

Comments
 (0)