Skip to content

Commit

Permalink
frequency: use simdutf8 in hot loop
Browse files Browse the repository at this point in the history
- not only faster coz of simd, but we also got rid of a to_vec() allocation
  • Loading branch information
jqnatividad committed May 22, 2023
1 parent d4a64ac commit 33406a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cmd/frequency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ impl Args {
row_work = row?;
for (i, field) in nsel.select(row_work.into_iter()).enumerate() {
field_work = {
match String::from_utf8(field.to_vec()) {
match simdutf8::basic::from_utf8(field) {
Ok(s) => s.trim().as_bytes().to_vec(),
Err(bs) => bs.into_bytes(),
Err(_) => field.to_vec(),
}
};
if !field_work.is_empty() {
Expand Down

0 comments on commit 33406a1

Please sign in to comment.