Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: experimentally use dupIO (take 2) #321

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cborg/cborg.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ library
bytestring >= 0.10.4 && < 0.12,
containers >= 0.5 && < 0.7,
deepseq >= 1.0 && < 1.5,
dupIO,
ghc-prim >= 0.3.1.0 && < 0.11,
half >= 0.2.2.3 && < 0.4,
primitive >= 0.5 && < 0.9,
Expand Down
6 changes: 5 additions & 1 deletion cborg/src/Codec/CBOR/Write.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ import qualified Codec.CBOR.ByteArray.Sliced as BAS
import Codec.CBOR.Encoding
import Codec.CBOR.Magic

import qualified Data.Dup as Dup

--------------------------------------------------------------------------------

-- | Turn an 'Encoding' into a lazy 'L.ByteString' in CBOR binary
Expand Down Expand Up @@ -110,7 +112,9 @@ buildStep vs1 k (BI.BufferRange op0 ope0) =
go vs1 op0
where
go vs !op
| op `plusPtr` bound <= ope0 = case vs of
| op `plusPtr` bound <= ope0 = do
dup_vs <- Dup.dupIO vs
case dup_vs of
TkWord x vs' -> PI.runB wordMP x op >>= go vs'
TkWord64 x vs' -> PI.runB word64MP x op >>= go vs'

Expand Down
2 changes: 1 addition & 1 deletion serialise/src/Codec/Serialise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ hPutSerialise :: Serialise a
=> Handle -- ^ The @'Handle'@ to write to.
-> a -- ^ The value to be serialised and written.
-> IO ()
hPutSerialise hnd x = BS.hPut hnd (serialise x)
hPutSerialise hnd x = BS.hPutBuilder hnd (CBOR.Write.toBuilder (encode x))

-- | Serialise a @'BS.ByteString'@ and write it directly to the
-- specified file.
Expand Down