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 @@ -13,7 +13,6 @@ use io::prelude::*;
13
13
14
14
use cmp;
15
15
use io:: { self , SeekFrom , Error , ErrorKind } ;
16
- use iter:: repeat;
17
16
use slice;
18
17
19
18
/// 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
143
let pos = self . position ( ) ;
145
144
let amt = pos. saturating_sub ( self . inner . len ( ) as u64 ) ;
146
- self . inner . extend ( repeat ( 0 ) . take ( amt as usize ) ) ;
145
+ // use `resize` so that the zero filling is as efficient as possible
146
+ let len = self . inner . len ( ) ;
147
+ self . inner . resize ( len + amt as usize , 0 ) ;
147
148
148
149
// Figure out what bytes will be used to overwrite what's currently
149
150
// there (left), and what will be appended on the end (right)
You can’t perform that action at this time.
0 commit comments