File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -384,14 +384,15 @@ where
384
384
}
385
385
}
386
386
387
- match r. read ( & mut g. buf [ g. len ..] ) {
387
+ let buf = & mut g. buf [ g. len ..] ;
388
+ match r. read ( buf) {
388
389
Ok ( 0 ) => return Ok ( g. len - start_len) ,
389
390
Ok ( n) => {
390
391
// We can't let g.len overflow which would result in the vec shrinking when the function returns. In
391
392
// particular, that could break read_to_string if the shortened buffer doesn't end on a UTF-8 boundary.
392
393
// The minimal check would just be a checked_add, but this assert is a bit more precise and should be
393
394
// just about the same cost.
394
- assert ! ( n <= g . buf. len( ) - g . len ) ;
395
+ assert ! ( n <= buf. len( ) ) ;
395
396
g. len += n;
396
397
}
397
398
Err ( ref e) if e. kind ( ) == ErrorKind :: Interrupted => { }
You can’t perform that action at this time.
0 commit comments