diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index a014d6e68ffb1..c6335015d7251 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -101,18 +101,14 @@ fn append_to_string(buf: &mut String, f: F) -> Result fn read_to_end(r: &mut R, buf: &mut Vec) -> Result { let start_len = buf.len(); let mut len = start_len; - let mut cap_bump = 16; + let mut new_write_size = 16; let ret; loop { if len == buf.len() { - if buf.capacity() == buf.len() { - if cap_bump < DEFAULT_BUF_SIZE { - cap_bump *= 2; - } - buf.reserve(cap_bump); + if new_write_size < DEFAULT_BUF_SIZE { + new_write_size *= 2; } - let new_area = buf.capacity() - buf.len(); - buf.extend(iter::repeat(0).take(new_area)); + buf.extend(iter::repeat(0).take(new_write_size)); } match r.read(&mut buf[len..]) {