@@ -1166,10 +1166,6 @@ fn dd_copy(mut i: Input, o: Output) -> io::Result<()> {
11661166 ) ;
11671167 }
11681168
1169- // Create a common buffer with a capacity of the block size.
1170- // This is the max size needed.
1171- let mut buf = vec ! [ BUF_INIT_BYTE ; bsize] ;
1172-
11731169 // Spawn a timer thread to provide a scheduled signal indicating when we
11741170 // should send an update of our progress to the reporting thread.
11751171 //
@@ -1201,6 +1197,11 @@ fn dd_copy(mut i: Input, o: Output) -> io::Result<()> {
12011197 BlockWriter :: Unbuffered ( o)
12021198 } ;
12031199
1200+ // Create a common empty buffer with a capacity of the block size.
1201+ // This is the max size needed.
1202+ let mut buf = Vec :: new ( ) ;
1203+ buf. try_reserve ( bsize) ?; // try_with_capacity is unstable https://github.com/rust-lang/rust/issues/91913
1204+
12041205 // The main read/write loop.
12051206 //
12061207 // Each iteration reads blocks from the input and writes
@@ -1366,6 +1367,7 @@ fn read_helper(i: &mut Input, buf: &mut Vec<u8>, bsize: usize) -> io::Result<Rea
13661367 // ------------------------------------------------------------------
13671368 // Read
13681369 // Resize the buffer to the bsize. Any garbage data in the buffer is overwritten or truncated, so there is no need to fill with BUF_INIT_BYTE first.
1370+ // resizing buf cause serious performance drop https://github.com/uutils/coreutils/issues/11544
13691371 buf. resize ( bsize, BUF_INIT_BYTE ) ;
13701372
13711373 let mut rstat = match i. settings . iconv . sync {
0 commit comments