JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.65k stars 1.05k forks source link

Change order of checks in default ShouldQuote implementation #2193

Closed alitas closed 6 months ago

alitas commented 10 months ago

This PR moves the space checks before the quote check & moves new line checks before the delimiter check. While it will definitely depend on the input data, this change sorting the comparisons from fastest to potentially the slowest one should help with the performance.

JoshClose commented 6 months ago

I believe @nicemanman meant to create a function for StartsWith that the user could override. Changing to StartsWith over [0] will be slower, so I am changing that part back.

This will all be replaced with SIMD operations in the future anyways.