Skip to content

Commit

Permalink
cat: use empty_byte_record to skip one more allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Oct 6, 2023
1 parent 5b35abb commit 58ee11c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cmd/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ impl Args {
for c in &columns_global {
wtr.write_field(c)?;
}
wtr.write_byte_record(&csv::ByteRecord::new())?;
let empty_byte_record = csv::ByteRecord::new();
wtr.write_byte_record(&empty_byte_record)?;

// amortize allocations
#[allow(unused_assignments)]
Expand All @@ -159,7 +160,6 @@ impl Args {
let mut h: &csv::ByteRecord;
let mut columns_of_this_file = IndexMap::with_capacity(num_columns_global);
let mut row: csv::ByteRecord;
let empty_byte_record = csv::ByteRecord::new();

for conf in self.configs()? {
if conf.is_stdin() {
Expand Down

0 comments on commit 58ee11c

Please sign in to comment.