wrengr / bytestring-lexing

Efficiently parse and produce common lexemes: namely integral and fractional numbers.
Other
6 stars 4 forks source link

Add fast lexers for Integer and Natural #3

Open treeowl opened 8 years ago

treeowl commented 8 years ago

Bertram Felgenhauer has written one for strings that should translate well for decimal conversion.

byteArrayToBigNat# should let you write something absurdly fast for hexadecimal and (if you think it's worth the trouble) octal. Count the digits to determine how many bytes you need, round up to the nearest multiple of the word size, allocate a MutableByteArray#, fill it up with words (I think) smallest first, unsafe freeze it, and then convert for free. Special case numbers that fit in one word.