Shim out writeCharArray# when bounds checking is on
This commit is contained in:
parent
3e8e438109
commit
43a2049168
3 changed files with 10 additions and 1 deletions
|
@ -45,6 +45,7 @@ library
|
||||||
Data.Bytes.Builder.Bounded.Unsafe
|
Data.Bytes.Builder.Bounded.Unsafe
|
||||||
other-modules:
|
other-modules:
|
||||||
Compat
|
Compat
|
||||||
|
Op
|
||||||
reexported-modules:
|
reexported-modules:
|
||||||
Data.Bytes.Chunks
|
Data.Bytes.Chunks
|
||||||
build-depends:
|
build-depends:
|
||||||
|
@ -68,8 +69,10 @@ library
|
||||||
hs-source-dirs: src-9.0
|
hs-source-dirs: src-9.0
|
||||||
if flag(checked)
|
if flag(checked)
|
||||||
build-depends: primitive-checked >= 0.7 && <0.8
|
build-depends: primitive-checked >= 0.7 && <0.8
|
||||||
|
hs-source-dirs: src-checked
|
||||||
else
|
else
|
||||||
build-depends: primitive >= 0.7 && <0.8
|
build-depends: primitive >= 0.7 && <0.8
|
||||||
|
hs-source-dirs: src-unchecked
|
||||||
ghc-options: -Wall -O2
|
ghc-options: -Wall -O2
|
||||||
hs-source-dirs: src
|
hs-source-dirs: src
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
{-# language MagicHash #-}
|
||||||
|
{-# language UnboxedTuples #-}
|
||||||
|
|
||||||
module Op
|
module Op
|
||||||
( writeCharArray#
|
( writeCharArray#
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import GHC.Exts ((<#),(>=#))
|
import GHC.Exts ((<#),(>=#))
|
||||||
|
import GHC.Int (Int(I#))
|
||||||
import qualified GHC.Exts as Exts
|
import qualified GHC.Exts as Exts
|
||||||
|
|
||||||
writeCharArray# :: Exts.MutableByteArray# s -> Exts.Int# -> Exts.Char# -> Exts.State# s -> Exts.State# s
|
writeCharArray# :: Exts.MutableByteArray# s -> Exts.Int# -> Exts.Char# -> Exts.State# s -> Exts.State# s
|
||||||
|
@ -11,4 +15,4 @@ writeCharArray# arr i v st = case i <# 0# of
|
||||||
_ -> case Exts.getSizeofMutableByteArray# arr st of
|
_ -> case Exts.getSizeofMutableByteArray# arr st of
|
||||||
(# st', sz #) -> case i >=# sz of
|
(# st', sz #) -> case i >=# sz of
|
||||||
1# -> error ("writeCharArray#: index " ++ show (I# i) ++ " >= length " ++ show (I# sz))
|
1# -> error ("writeCharArray#: index " ++ show (I# i) ++ " >= length " ++ show (I# sz))
|
||||||
_ -> Exts.writeInt8Array# arr i (Exts.intToInt8# v) st'
|
_ -> Exts.writeCharArray# arr i v st'
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
{-# language MagicHash #-}
|
||||||
|
|
||||||
module Op
|
module Op
|
||||||
( writeCharArray#
|
( writeCharArray#
|
||||||
) where
|
) where
|
||||||
|
|
Loading…
Reference in a new issue