Skip to content

Instantly share code, notes, and snippets.

@drchaos
Created May 3, 2023 16:21
Show Gist options
  • Save drchaos/a820125861f682c8991eaebe18d8cf04 to your computer and use it in GitHub Desktop.
Save drchaos/a820125861f682c8991eaebe18d8cf04 to your computer and use it in GitHub Desktop.
hashBS :: ByteString -> Word32
hashBS = B.foldl fnv1aHash32Base fnvOffsetBasis32
hashBS_unpack :: ByteString -> Word32
hashBS_unpack = foldl' fnv1aHash32Base fnvOffsetBasis32 . B.unpack
hashBS_С :: ByteString -> Word32
hashBS_С bs = B.unsafeDupablePerformIO $!
B.unsafeUseAsCStringLen bs (\ (ptr, l) -> fnv1a_32 (castPtr ptr) l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment