@@ -1956,38 +1956,41 @@ withoutKeys m (Set.Bin _ k ls rs) = case splitMember k m of
19561956-- @
19571957partitionKeys :: forall k a . Ord k => Map k a -> Set k -> (Map k a , Map k a )
19581958partitionKeys xs ys =
1959- case go xs ys of
1959+ case partitionKeysWorker xs ys of
19601960 xs' :*: ys' -> (xs', ys')
1961- where
1962- go :: Map k a -> Set k -> StrictPair (Map k a ) (Map k a )
1963- go Tip _ = Tip :*: Tip
1964- go m Set. Tip = Tip :*: m
1965- go m@ (Bin _ k x lm rm) s@ Set. Bin {} =
1966- case b of
1967- True -> with :*: without
1968- where
1969- with =
1970- if lmWith `ptrEq` lm && rmWith `ptrEq` rm
1971- then m
1972- else link k x lmWith rmWith
1973- without =
1974- link2 lmWithout rmWithout
1975- False -> with :*: without
1976- where
1977- with = link2 lmWith rmWith
1978- without =
1979- if lmWithout `ptrEq` lm && rmWithout `ptrEq` rm
1980- then m
1981- else link k x lmWithout rmWithout
1982- where
1983- ! (lmWith :*: lmWithout) = go lm ls'
1984- ! (rmWith :*: rmWithout) = go rm rs'
1985-
1986- ! (! ls', b, ! rs') = Set. splitMember k s
19871961#if __GLASGOW_HASKELL__
19881962{-# INLINABLE partitionKeys #-}
19891963#endif
19901964
1965+ partitionKeysWorker :: Ord k => Map k a -> Set k -> StrictPair (Map k a ) (Map k a )
1966+ partitionKeysWorker Tip _ = Tip :*: Tip
1967+ partitionKeysWorker m Set. Tip = Tip :*: m
1968+ partitionKeysWorker m@ (Bin _ k x lm rm) s@ Set. Bin {} =
1969+ case b of
1970+ True -> with :*: without
1971+ where
1972+ with =
1973+ if lmWith `ptrEq` lm && rmWith `ptrEq` rm
1974+ then m
1975+ else link k x lmWith rmWith
1976+ without =
1977+ link2 lmWithout rmWithout
1978+ False -> with :*: without
1979+ where
1980+ with = link2 lmWith rmWith
1981+ without =
1982+ if lmWithout `ptrEq` lm && rmWithout `ptrEq` rm
1983+ then m
1984+ else link k x lmWithout rmWithout
1985+ where
1986+ ! (lmWith :*: lmWithout) = partitionKeysWorker lm ls'
1987+ ! (rmWith :*: rmWithout) = partitionKeysWorker rm rs'
1988+
1989+ ! (! ls', b, ! rs') = Set. splitMember k s
1990+ #if __GLASGOW_HASKELL__
1991+ {-# INLINABLE partitionKeysWorker #-}
1992+ #endif
1993+
19911994-- | \(O(n+m)\). Difference with a combining function.
19921995-- When two equal keys are
19931996-- encountered, the combining function is applied to the values of these keys.
0 commit comments