We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a5cc17a commit 5b6a464Copy full SHA for 5b6a464
src/libstd/io/cursor.rs
@@ -13,7 +13,6 @@ use io::prelude::*;
13
14
use cmp;
15
use io::{self, SeekFrom, Error, ErrorKind};
16
-use iter::repeat;
17
use slice;
18
19
/// A `Cursor` is a type which wraps a non-I/O object to provide a `Seek`
@@ -143,7 +142,9 @@ impl Write for Cursor<Vec<u8>> {
143
142
// currently are
144
let pos = self.position();
145
let amt = pos.saturating_sub(self.inner.len() as u64);
146
- self.inner.extend(repeat(0).take(amt as usize));
+ // use `resize` so that the zero filling is as efficient as possible
+ let len = self.inner.len();
147
+ self.inner.resize(len + amt as usize, 0);
148
149
// Figure out what bytes will be used to overwrite what's currently
150
// there (left), and what will be appended on the end (right)
0 commit comments