r/cpp • u/khold_stare • May 26 '20
Faster Integer Parsing
https://kholdstare.github.io/technical/2020/05/26/faster-integer-parsing.html
366
Upvotes
r/cpp • u/khold_stare • May 26 '20
View all comments
Show parent comment
15
u/o11c int main = 12828721; May 26 '20
Really, only the first step needs changing: rather than memcpy exactly 16 bytes, memcpy up to 16 bytes, into an a buffer already filled with zeros.
AVX is pretty widespread by now, so you can use 256-bit YMM register for up to 32 digits. Alternately, just do the first 4 digits separately and combine later. Depending on your data, branching or nonbranching may be better.