@@ -33,8 +33,8 @@ import Control.Distributed.Process.Internal.StrictMVar
34import Control.Distributed.Process.Internal.StrictList
34import Control.Distributed.Process.Internal.StrictList
35 ( StrictList(..)
35 ( StrictList(..)
37−import qualified Control.Distributed.Process.Internal.StrictList as S
38import Data.Maybe (fromJust)
38import Data.Maybe (fromJust)
39import GHC.MVar (MVar(MVar))
39import GHC.MVar (MVar(MVar))
40import GHC.IO (IO(IO))
40import GHC.IO (IO(IO))
@@ -146,8 +146,8 @@ dequeue (CQueue arrived incoming) blockSpec matchons =
146 -- of passing around restore and setting up exception handlers is
146 -- of passing around restore and setting up exception handlers is
147 -- high. So just don't use expensive matchIfs!
147 -- high. So just don't use expensive matchIfs!
148 case checkArrived matches old of
148 case checkArrived matches old of
149− (old', Just r) -> returnOld old' (Just r)
149+ (old', Just r) -> returnOld old' (Just r)
150− (old', Nothing) -> goCheck rest old'
150+ (old', Nothing) -> goCheck rest old'
151 -- use the result list, which is now left-biased
151 -- use the result list, which is now left-biased
@@ -222,11 +222,16 @@ dequeue (CQueue arrived incoming) blockSpec matchons =
223 -- as a side-effect, this left-biases the list
223 -- as a side-effect, this left-biases the list
224 checkArrived :: [m -> Maybe a] -> StrictList m -> (StrictList m, Maybe a)
224 checkArrived :: [m -> Maybe a] -> StrictList m -> (StrictList m, Maybe a)
225− checkArrived matches list = S.foldr f (Nil, Nothing) list
225+ checkArrived matches list = go list Nil
227− f x (rest,r)
227+ go Nil Nil = (Nil, Nothing)
229+ go (Append xs ys) tl = go xs (append ys tl)
230+ go (Snoc xs x) tl = go xs (Cons x tl)
228− | Just y <- checkMatches matches x = (rest, Just y)
232+ | Just y <- checkMatches matches x = (Append xs tl, Just y)
229 | otherwise = (Cons x rest, r)
233 | otherwise = (Cons x rest, r)
234+ where !(rest,r) = go xs tl
231 checkMatches :: [m -> Maybe a] -> m -> Maybe a
236 checkMatches :: [m -> Maybe a] -> m -> Maybe a
232 checkMatches [] _ = Nothing
237 checkMatches [] _ = Nothing