wai-eventsource: Avoid mconcat and reverse on ioToRepEventSource.
This commit is contained in:
parent
600fec4852
commit
93b2c3acf1
@ -12,7 +12,7 @@ import Blaze.ByteString.Builder (Builder)
|
|||||||
import Control.Monad (when)
|
import Control.Monad (when)
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import Data.Functor ((<$>))
|
import Data.Functor ((<$>))
|
||||||
import Data.Monoid (mconcat)
|
import Data.Monoid (mappend, mempty)
|
||||||
import Yesod.Content
|
import Yesod.Content
|
||||||
import Yesod.Core
|
import Yesod.Core
|
||||||
import qualified Data.Conduit as C
|
import qualified Data.Conduit as C
|
||||||
@ -71,7 +71,7 @@ ioToRepEventSource initial act = do
|
|||||||
case evs of
|
case evs of
|
||||||
[] -> getEvents s'
|
[] -> getEvents s'
|
||||||
_ -> do
|
_ -> do
|
||||||
let (builder, continue) = joinEvents evs []
|
let (builder, continue) = joinEvents evs mempty
|
||||||
C.yield (C.Chunk builder)
|
C.yield (C.Chunk builder)
|
||||||
C.yield C.Flush
|
C.yield C.Flush
|
||||||
when continue (getEvents s')
|
when continue (getEvents s')
|
||||||
@ -80,9 +80,9 @@ ioToRepEventSource initial act = do
|
|||||||
-- when we the connection should be closed.
|
-- when we the connection should be closed.
|
||||||
joinEvents (ev:evs) acc =
|
joinEvents (ev:evs) acc =
|
||||||
case ES.eventToBuilder ev of
|
case ES.eventToBuilder ev of
|
||||||
Just b -> joinEvents evs (b:acc)
|
Just b -> joinEvents evs (acc `mappend` b)
|
||||||
Nothing -> (fst $ joinEvents [] acc, False)
|
Nothing -> (fst $ joinEvents [] acc, False)
|
||||||
joinEvents [] acc = (mconcat (reverse acc), True)
|
joinEvents [] acc = (acc, True)
|
||||||
|
|
||||||
return $ RepEventSource $ getEvents initial
|
return $ RepEventSource $ getEvents initial
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user