File tree Expand file tree Collapse file tree 1 file changed +28
-8
lines changed
plutus-core/flat/src/PlutusCore/Flat/Decoder Expand file tree Collapse file tree 1 file changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -55,15 +55,35 @@ import Numeric.Natural (Natural)
5555import PlutusCore.Flat.Data.ZigZag
5656#include "MachDeps.h"
5757
58- {-# INLINE decodeListWith #-}
5958decodeListWith :: Get a -> Get [a ]
60- decodeListWith dec = go
61- where
62- go = do
63- b <- dBool
64- if b
65- then (:) <$> dec <*> go
66- else return []
59+ decodeListWith dec = do
60+ b <- dBool
61+ if b
62+ then Get $
63+ \ end s -> do
64+ GetResult s' h <- runGet dec end s
65+ if s' /= s
66+ then
67+ let goNormal = do
68+ b <- dBool
69+ if b
70+ then (:) <$> dec <*> goNormal
71+ else pure []
72+ {-# INLINE goNormal #-}
73+ in runGet ((h: ) <$> goNormal) end s'
74+ else
75+ let goZero x =
76+ let goZero'= do
77+ b <- dBool
78+ if b
79+ then (x: ) <$> goZero'
80+ else pure []
81+ {-# INLINE goZero' #-}
82+ in goZero'
83+ {-# INLINE goZero #-}
84+ in runGet ((h: ) <$> goZero h) end s'
85+ else pure []
86+ {-# INLINE decodeListWith #-}
6787
6888decodeArrayWith :: Get a -> Get [a ]
6989decodeArrayWith dec = DL. toList <$> getAsL_ dec
You can’t perform that action at this time.
0 commit comments