emilypi / Base16

BSD 3-Clause "New" or "Revised" License
4 stars 8 forks source link

`is(Valid)Base16` optimizations #27

Closed Vlix closed 8 months ago

Vlix commented 1 year ago

24

I've tried some things, but the "index into an Array# to check" seems to be the fastest.

In most cases the improvement for isValidBase16 is almost an order of magnitude (about 6-7x faster). The isBase16 case is about 9x faster, though just running isRight (decodeBase16Untyped bs) is VERY close in speed (though it obviously uses more memory).

The lazy variants are even faster. About 10-20x.

Vlix commented 8 months ago

I'll adjust according to comments the next time I can get to work on this. 👍

Vlix commented 8 months ago

Never thought I'd ever use accursedUnutterablePerformIO 😅 but it does seem to speed it up even more (when I run the benchmarks) foldrChunks also removes the need to rename (s)bs.

Everything seems to be done now :)

emilypi commented 8 months ago

Awesome thanks @Vlix :)