Skip to content

Commit

Permalink
WIP: experimentally use dupIO to fix #318
Browse files Browse the repository at this point in the history
This calls dupIO before evaluating each token in the token stream.
  • Loading branch information
adamgundry committed Aug 18, 2023
1 parent ba334b8 commit 3141522
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions cborg/cborg.cabal
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
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

0 comments on commit 3141522

Please sign in to comment.