The SWAR algorithm accepts the 6 ASCII characters after '9'. It'll parse ":>" as 114.<p><pre><code> int res = parse_uint8_fastswar(":>\0", 2, &num);
</code></pre>
Returns true and num is 114.
I tried this out but it parsed the string "123\n" as 32.<p>Also it parses "400" as 144, when the reference implementation considers it not-a-uint8, but I don't mind so much about that.<p>EDIT: Ah, I think it assumes the string contains <i>only</i> a uint8, rather than trying to parse a uint8 from the start of a string. So you need to zero out the "\n" separately, and then it works.
Looking forward to "parsing bit sequences in roman literals quickly"<p><a href="https://hn.algolia.com/?q=lemire+parsing" rel="nofollow noreferrer">https://hn.algolia.com/?q=lemire+parsing</a>
I imagine that you are not allowed to allocate a constant array that would contain a mapping between ASCII values of integers and the actual ints :)? The're just 255 of them needed. Or woukd it be slower?
dlemire, you note that the read ”overflows”. Why can’t you copy just `len` bytes? Does it slow too much because of the branch/more load/store operations?
Fetching the data should be the bottleneck (by far), so why is the naive approach 2x slower than this smarter approach?<p>Sounds like the CPU should be designed in a smarter way, not the code.
i am so confused.<p>"you are given a string and it's length".. i dont understand.<p>is the string like "1,1,22,2,189,3,12,2,120,3" ???