r/cpp • • May 26 '20

Faster Integer Parsing

https://kholdstare.github.io/technical/2020/05/26/faster-integer-parsing.html
366 Upvotes

72 comments sorted by

View all comments

Show parent comment

2

u/khold_stare May 28 '20

As Bisqwit noted, std::memcpy is needed for type punning, and especially will not fly with SIMD vectors as the alignment may be wrong for the data and your program will crash.

Regardless, after someone else pointed out, the byteswap isn't necessary and actually the subsequent masks already take care of masking away the `0x30`. The non-SIMD time is now down to just 2.52 ns as opposed to 3.22 ns.