Skip to content

Commit

Permalink
excel: replace clone with take in hot loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Mar 27, 2024
1 parent 80bd767 commit 8496157
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cmd/excel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,10 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
trimmed_record.clear();
}

processed_chunk.push(record.clone());
record.clear();
// we use mem::take here to avoid a clone/allocation of the record
// it also has the nice side-effect of clearing the record, so we don't
// need to call clear() on it.
processed_chunk.push(std::mem::take(&mut record));
}
processed_chunk
})
Expand Down

0 comments on commit 8496157

Please sign in to comment.