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
4 changes: 3 additions & 1 deletion csv-core/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,9 @@ impl Reader {
let mut state = self.dfa_state;
while nin < input.len() && nout < output.len() && nend < ends.len() {
let (s, has_out) = self.dfa.get_output(state, input[nin]);
self.line += (input[nin] == b'\n') as u64;
if input[nin] == b'\n'{
self.line += 1;
}
Comment on lines +669 to +671

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have benchmarks backing this up? I'm a little skeptical that the cost of looking up self.line in order to increment it by zero is higher than the cost of adding a branch in the code path, at least on most modern CPUs where branches do unpleasant things to instruction pipelining.

state = s;
if has_out {
output[nout] = input[nin];
Expand Down