We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 44c93ce commit 6adc9e6Copy full SHA for 6adc9e6
src/libstd/io/mod.rs
@@ -366,6 +366,17 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
366
fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize> {
367
let start_len = buf.len();
368
let mut g = Guard { len: buf.len(), buf: buf };
369
+
370
+ let size_hint = r.size_hint();
371
+ if size_hint > 0 {
372
+ unsafe {
373
+ g.buf.reserve(size_hint);
374
+ let capacity = g.buf.capacity();
375
+ g.buf.set_len(capacity);
376
+ r.initializer().initialize(&mut g.buf[g.len..]);
377
+ }
378
379
380
loop {
381
if g.len == g.buf.len() {
382
unsafe {
0 commit comments