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