haskell / attoparsec

A fast Haskell library for parsing ByteStrings
http://hackage.haskell.org/package/attoparsec
Other
512 stars 93 forks source link

Use special unsigned tests to reduce branches for isDigit_w8, isSpace_w8 #81

Closed kvanbere closed 9 years ago

kvanbere commented 10 years ago

50% branch reduction, yeahhh.

I haven't been able to get the benchmark suite working (cyclic dependencies?) so I only ran tests for this.

kvanbere commented 10 years ago

If fromIntegral is free, it could even be worth expressing isDigit in terms of an unsigned version using fromIntegral for the same branch reduction.

cartazio commented 10 years ago

@kvanberendonck I see you haven't done benchmarks mentioned. Do you have any benchmarks you care to share to validate this change? Or testing? (or failing tests, proofs?)

kvanbere commented 10 years ago

As I said, it passes tests but I can't get the benchmark suite working.

There's also an alternate implementation which might be even faster for isDigit_w8:

isDigit_w8 w = (w `xor` 48)  < 10
kvanbere commented 10 years ago

@bos

bos commented 9 years ago

I applied this even though I can't measure a difference. c6a54d1b1893ba8167f6ec48f6936752d3fd98f3 fixes it up a little.