rust-csv
rust-csv copied to clipboard
Performance issue with the redundancy operations
https://github.com/BurntSushi/rust-csv/blob/41c71ed353a71526c52633d854466c1619dacae4/csv-core/src/reader.rs#L669
For this line of code, it will always update the value of self.line, even if the value of it does not change. This introduces some redundant operations.
If we change the code to this, we can eliminate these redundant operations.
if input[nin] == b'\n'{
self.line += 1;
}
According to my tests with the ema example with this application (https://github.com/greyblake/ta-rs), the average execution time decreased from 2.74s to 2.68s, which is a 1.02x speedup.
Hope this information helps!
Interesting. Seems like the compiler should be smarter than that here. But happy to make this change. PRs are welcome.