Add a comment documenting the thought process behind encoding Word8s as decimal
This commit is contained in:
parent
61871a9ae3
commit
0b6317a4f5
1 changed files with 8 additions and 1 deletions
|
@ -172,7 +172,14 @@ word16Dec (W16# w) = wordCommonDec# w
|
||||||
-- | Requires up to 3 bytes. Encodes an unsigned 8-bit integer as decimal.
|
-- | Requires up to 3 bytes. Encodes an unsigned 8-bit integer as decimal.
|
||||||
-- This encoding never starts with a zero unless the argument was zero.
|
-- This encoding never starts with a zero unless the argument was zero.
|
||||||
word8Dec :: Word8 -> Builder 3
|
word8Dec :: Word8 -> Builder 3
|
||||||
word8Dec (W8# w) = word8Dec# w
|
word8Dec (W8# w) =
|
||||||
|
-- We unroll the loop when encoding Word8s. This speeds things
|
||||||
|
-- up IPv4 encoding by about 10% in the @ip@ library. We can
|
||||||
|
-- encode Word8s at twice this speed by using a lookup table.
|
||||||
|
-- However, I (Andrew Martin) am concerned that although lookup
|
||||||
|
-- table perform very well in microbenchmarks, they can thrash
|
||||||
|
-- L1 cache in real applications.
|
||||||
|
word8Dec# w
|
||||||
|
|
||||||
-- | Requires up to 19 bytes. Encodes an unsigned machine-sized integer
|
-- | Requires up to 19 bytes. Encodes an unsigned machine-sized integer
|
||||||
-- as decimal. This encoding never starts with a zero unless the argument
|
-- as decimal. This encoding never starts with a zero unless the argument
|
||||||
|
|
Loading…
Reference in a new issue