Not using memchr when parsing?
#398
-
|
Hello @BurntSushi, out of curiosity I was wondering why your |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
IIRC, I tried using That's generally consistent with my understanding of There are perhaps more speculative optimizations. Like, you could maybe run This is a good example of how it can be difficult to optimize a general purpose library. If you know what your data looks like (i.e., you know your CSV data has tons of large fields with little escaping), then you can write something simpler than this library that parses it more quickly than this library. |
Beta Was this translation helpful? Give feedback.
IIRC, I tried using
memchrbecause of a similar inclination when I wrote the parser. I can't remember the results, but IIRC, it improved some cases (CSV data with a lot of large fields) but regressed other cases (CSV data with short fields). I perceive the latter as more common. That is, while some CSV data might have a column or two with longer fields, I think most fields are very short (e.g., numbers). In this case, the overhead of starting and stopping memchr on each field ends up being slower.That's generally consistent with my understanding of
memchr. That is,haystack.iter().position(|&b| b == needle)is likely to be a hair faster one very tiny haystacks because there is less start…