File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,11 @@ flag optimize-gmp
59
59
manual : False
60
60
description : Use optimized code paths for integer-gmp
61
61
62
+ flag dupIO
63
+ default : False
64
+ manual : True
65
+ description : Use dupIO to avoid unwanted sharing when encoding
66
+
62
67
--------------------------------------------------------------------------------
63
68
-- Library
64
69
@@ -100,6 +105,10 @@ library
100
105
primitive >= 0.5 && < 0.10 ,
101
106
text >= 1.1 && < 1.3 || >= 2.0 && < 2.2
102
107
108
+ if flag(dupIO)
109
+ cpp-options : -DDUPIO
110
+ build-depends : dupIO >= 0.1.0 && < 0.2
111
+
103
112
if flag(optimize-gmp)
104
113
cpp-options : -DOPTIMIZE_GMP
105
114
if impl(ghc >= 9.0 )
Original file line number Diff line number Diff line change @@ -75,6 +75,10 @@ import qualified Codec.CBOR.ByteArray.Sliced as BAS
75
75
import Codec.CBOR.Encoding
76
76
import Codec.CBOR.Magic
77
77
78
+ #if defined(DUPIO)
79
+ import qualified Data.Dup as Dup
80
+ #endif
81
+
78
82
--------------------------------------------------------------------------------
79
83
80
84
-- | Turn an 'Encoding' into a lazy 'L.ByteString' in CBOR binary
@@ -110,7 +114,13 @@ buildStep vs1 k (BI.BufferRange op0 ope0) =
110
114
go vs1 op0
111
115
where
112
116
go vs ! op
113
- | op `plusPtr` bound <= ope0 = case vs of
117
+ | op `plusPtr` bound <= ope0 = do
118
+ #if defined(DUPIO)
119
+ dup_vs <- Dup. dupIO vs
120
+ case dup_vs of
121
+ #else
122
+ case vs of
123
+ #endif
114
124
TkWord x vs' -> PI. runB wordMP x op >>= go vs'
115
125
TkWord64 x vs' -> PI. runB word64MP x op >>= go vs'
116
126
You can’t perform that action at this time.
0 commit comments