Skip to content

Unroll loops to decode unsigned integers #164

@mchav

Description

@mchav

We use loop structures to decode bytes:

littleEndianWord64 :: BS.ByteString -> Word64
littleEndianWord64 bytes =
    foldr
        (.|.)
        0
        ( zipWith
            (\b i -> fromIntegral b `shiftL` i)
            (BS.unpack $ BS.take 8 bytes)
            [0, 8 ..]
        )

These loops can be unrolled to something like https://hackage.haskell.org/package/binary-0.8.9.3/docs/src/Data.Binary.Get.html#word64be

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions