@@ -1979,38 +1979,41 @@ withoutKeys m (Set.Bin _ k ls rs) = case splitMember k m of
19791979-- @
19801980partitionKeys :: forall k a . Ord k => Map k a -> Set k -> (Map k a , Map k a )
19811981partitionKeys xs ys =
1982- case go xs ys of
1982+ case partitionKeysWorker xs ys of
19831983 xs' :*: ys' -> (xs', ys')
1984- where
1985- go :: Map k a -> Set k -> StrictPair (Map k a ) (Map k a )
1986- go Tip _ = Tip :*: Tip
1987- go m Set. Tip = Tip :*: m
1988- go m@ (Bin _ k x lm rm) s@ Set. Bin {} =
1989- case b of
1990- True -> with :*: without
1991- where
1992- with =
1993- if lmWith `ptrEq` lm && rmWith `ptrEq` rm
1994- then m
1995- else link k x lmWith rmWith
1996- without =
1997- link2 lmWithout rmWithout
1998- False -> with :*: without
1999- where
2000- with = link2 lmWith rmWith
2001- without =
2002- if lmWithout `ptrEq` lm && rmWithout `ptrEq` rm
2003- then m
2004- else link k x lmWithout rmWithout
2005- where
2006- ! (lmWith :*: lmWithout) = go lm ls'
2007- ! (rmWith :*: rmWithout) = go rm rs'
2008-
2009- ! (! ls', b, ! rs') = Set. splitMember k s
20101984#if __GLASGOW_HASKELL__
20111985{-# INLINABLE partitionKeys #-}
20121986#endif
20131987
1988+ partitionKeysWorker :: Ord k => Map k a -> Set k -> StrictPair (Map k a ) (Map k a )
1989+ partitionKeysWorker Tip _ = Tip :*: Tip
1990+ partitionKeysWorker m Set. Tip = Tip :*: m
1991+ partitionKeysWorker m@ (Bin _ k x lm rm) s@ Set. Bin {} =
1992+ case b of
1993+ True -> with :*: without
1994+ where
1995+ with =
1996+ if lmWith `ptrEq` lm && rmWith `ptrEq` rm
1997+ then m
1998+ else link k x lmWith rmWith
1999+ without =
2000+ link2 lmWithout rmWithout
2001+ False -> with :*: without
2002+ where
2003+ with = link2 lmWith rmWith
2004+ without =
2005+ if lmWithout `ptrEq` lm && rmWithout `ptrEq` rm
2006+ then m
2007+ else link k x lmWithout rmWithout
2008+ where
2009+ ! (lmWith :*: lmWithout) = partitionKeysWorker lm ls'
2010+ ! (rmWith :*: rmWithout) = partitionKeysWorker rm rs'
2011+
2012+ ! (! ls', b, ! rs') = Set. splitMember k s
2013+ #if __GLASGOW_HASKELL__
2014+ {-# INLINABLE partitionKeysWorker #-}
2015+ #endif
2016+
20142017-- | \(O(n+m)\). Difference with a combining function.
20152018-- When two equal keys are
20162019-- encountered, the combining function is applied to the values of these keys.
0 commit comments