Copyright | (c) Dong Han 2017-2018 |
---|---|
License | BSD |
Maintainer | winterland1989@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
This module implement some bit twiddling with ghc primitives.
We currently didn't use all functions from this module though: the performance is not catching up c version yet. But this module and relevant benchmarks are kept in hope that once we have fully SIMD support in GHC, we might optimize these functions further to compete with c.
Reference:
Synopsis
- isOffsetAligned# :: Int# -> Bool
- mkMask# :: Word# -> Word#
- nullByteMagic# :: Word# -> Word#
- memchr :: PrimArray Word8 -> Word8 -> Int -> Int -> Int
- memchr# :: ByteArray# -> Word# -> Int# -> Int# -> Int#
- memchrReverse :: PrimArray Word8 -> Word8 -> Int -> Int -> Int
- memchrReverse# :: ByteArray# -> Word# -> Int# -> Int# -> Int#
- c_memchr :: ByteArray# -> Int -> Word8 -> Int -> Int
Documentation
isOffsetAligned# :: Int# -> Bool Source #
nullByteMagic# :: Word# -> Word# Source #
memchr :: PrimArray Word8 -> Word8 -> Int -> Int -> Int Source #
Search a word8 in array.
Currently this function is ~4 times slow than c version, so we didn't use it.
memchrReverse :: PrimArray Word8 -> Word8 -> Int -> Int -> Int Source #
Search a word8 array in reverse order.
This function is used in elemIndexEnd
, since there's no c equivalent.
memchrReverse# :: ByteArray# -> Word# -> Int# -> Int# -> Int# Source #
The unboxed version of memchrReverse