mirror of
https://github.com/ilyakooo0/streamly.git
synced 2024-09-11 08:25:40 +03:00
Fix O(n) space issue in evalStateT/runStateT
Added strictness annotation. Space consumption now is O(1).
This commit is contained in:
parent
28e17ee82e
commit
8072636a12
@ -92,7 +92,7 @@ evalStateT initial (Stream step state) = Stream step' (state, initial)
|
||||
{-# INLINE_LATE step' #-}
|
||||
step' gst (st, action) = do
|
||||
sv <- action
|
||||
(r, sv') <- State.runStateT (step (adaptState gst) st) sv
|
||||
(r, !sv') <- State.runStateT (step (adaptState gst) st) sv
|
||||
return $ case r of
|
||||
Yield x s -> Yield x (s, return sv')
|
||||
Skip s -> Skip (s, return sv')
|
||||
@ -105,7 +105,7 @@ runStateT initial (Stream step state) = Stream step' (state, initial)
|
||||
{-# INLINE_LATE step' #-}
|
||||
step' gst (st, action) = do
|
||||
sv <- action
|
||||
(r, sv') <- State.runStateT (step (adaptState gst) st) sv
|
||||
(r, !sv') <- State.runStateT (step (adaptState gst) st) sv
|
||||
return $ case r of
|
||||
Yield x s -> Yield (sv', x) (s, return sv')
|
||||
Skip s -> Skip (s, return sv')
|
||||
|
Loading…
Reference in New Issue
Block a user