Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/uu/split/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ where
out_files = OutFiles::init(num_chunks, settings, false)?;
}

let buf = &mut Vec::new();
let mut buf = Vec::with_capacity((chunk_size_base + 1) as usize);
for i in 1_u64..=num_chunks {
let chunk_size = chunk_size_base + (chunk_size_reminder > i - 1) as u64;
buf.clear();
Expand All @@ -1175,7 +1175,7 @@ where
}
};

let n_bytes_read = reader.by_ref().take(limit).read_to_end(buf);
let n_bytes_read = reader.by_ref().take(limit).read_to_end(&mut buf);

match n_bytes_read {
Ok(n_bytes) => {
Expand All @@ -1191,13 +1191,13 @@ where

if let Some(chunk_number) = kth_chunk {
if i == chunk_number {
stdout_writer.write_all(buf)?;
stdout_writer.write_all(&buf)?;
break;
}
} else {
let idx = (i - 1) as usize;
let writer = out_files.get_writer(idx, settings)?;
writer.write_all(buf)?;
writer.write_all(&buf)?;
}
} else {
break;
Expand Down
Loading