Skip to content

Commit 4d47bd5

Browse files
committed
Adjust where we evaluate selecting out the marked byte span.
Better to do it in the reader.
1 parent 45a1a7c commit 4d47bd5

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

cborg/src/Codec/CBOR/Decoding.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ decodeWithByteSpan :: Decoder s a -> Decoder s (a, ByteSpan)
11331133
decodeWithByteSpan da = do
11341134
openByteSpan
11351135
x <- da
1136-
!bs <- peekByteSpan
1136+
bs <- peekByteSpan
11371137
closeByteSpan
11381138
return (x, bs)
11391139

cborg/src/Codec/CBOR/Read.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ go_slow da bs !offset !marks = do
13571357
!offset' = offset + intToInt64 (BS.length bs - BS.length bs')
13581358

13591359
SlowPeekByteSpan bs' k ->
1360-
lift (k (peekMarkedByteSpan offset' marks)) >>= \daz -> go_slow daz bs' offset' marks
1360+
lift (k $! peekMarkedByteSpan offset' marks) >>= \daz -> go_slow daz bs' offset' marks
13611361
where
13621362
!offset' = offset + intToInt64 (BS.length bs - BS.length bs')
13631363

@@ -1480,7 +1480,7 @@ go_slow_overlapped da sz bs_cur bs_next !offset !marks =
14801480
lift k >>= \daz -> go_slow daz bs' offset' (unmarkByteSpan marks)
14811481
SlowPeekByteSpan bs_empty k ->
14821482
assert (BS.null bs_empty) $
1483-
lift (k (peekMarkedByteSpan offset' marks)) >>= \daz -> go_slow daz bs' offset' marks
1483+
lift (k $! peekMarkedByteSpan offset' marks) >>= \daz -> go_slow daz bs' offset' marks
14841484

14851485
SlowFail bs_unconsumed msg ->
14861486
decodeFail (bs_unconsumed <> bs') offset'' msg

0 commit comments

Comments
 (0)