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 on the token stream each time the buffer is full.
  • Loading branch information
adamgundry committed May 24, 2023
1 parent ec399a1 commit b996afc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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
5 changes: 4 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 @@ -194,7 +196,8 @@ buildStep vs1 k (BI.BufferRange op0 ope0) =

TkEnd -> k (BI.BufferRange op ope0)

| otherwise = return $ BI.bufferFull bound op (buildStep vs k)
| otherwise = do vs' <- Dup.dupIO vs
return $ BI.bufferFull bound op (buildStep vs' k)

-- The maximum size in bytes of the fixed-size encodings
bound :: Int
Expand Down

0 comments on commit b996afc

Please sign in to comment.