Skip to content

Commit 3141522

Browse files
committed
WIP: experimentally use dupIO to fix #318
This calls dupIO before evaluating each token in the token stream.
1 parent ba334b8 commit 3141522

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

cborg/cborg.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ library
9494
bytestring >= 0.10.4 && < 0.12,
9595
containers >= 0.5 && < 0.7,
9696
deepseq >= 1.0 && < 1.5,
97+
dupIO,
9798
ghc-prim >= 0.3.1.0 && < 0.11,
9899
half >= 0.2.2.3 && < 0.4,
99100
primitive >= 0.5 && < 0.9,

cborg/src/Codec/CBOR/Write.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ import qualified Codec.CBOR.ByteArray.Sliced as BAS
7575
import Codec.CBOR.Encoding
7676
import Codec.CBOR.Magic
7777

78+
import qualified Data.Dup as Dup
79+
7880
--------------------------------------------------------------------------------
7981

8082
-- | Turn an 'Encoding' into a lazy 'L.ByteString' in CBOR binary
@@ -110,7 +112,9 @@ buildStep vs1 k (BI.BufferRange op0 ope0) =
110112
go vs1 op0
111113
where
112114
go vs !op
113-
| op `plusPtr` bound <= ope0 = case vs of
115+
| op `plusPtr` bound <= ope0 = do
116+
dup_vs <- Dup.dupIO vs
117+
case dup_vs of
114118
TkWord x vs' -> PI.runB wordMP x op >>= go vs'
115119
TkWord64 x vs' -> PI.runB word64MP x op >>= go vs'
116120

0 commit comments

Comments
 (0)