[Git][ghc/ghc][wip/sjakobi/set-ops] Ensure that SetOps.{minusList,unionListsOrd} can be specialized
Simon Jakobi pushed to branch wip/sjakobi/set-ops at Glasgow Haskell Compiler / GHC Commits: 092fcbbe by Simon Jakobi at 2026-05-25T09:06:36+02:00 Ensure that SetOps.{minusList,unionListsOrd} can be specialized ...by marking them INLINABLE. Haddock allocates 0.1–0.3% less as a result. This also removes some redundant constraints on unionListsOrd. - - - - - 1 changed file: - compiler/GHC/Data/List/SetOps.hs Changes: ===================================== compiler/GHC/Data/List/SetOps.hs ===================================== @@ -60,12 +60,13 @@ getNth xs n = assertPpr (xs `lengthExceeds` n) (ppr n $$ ppr xs) $ -- -- Uses a set internally to record duplicates. This makes it slightly slower for -- very small lists but avoids quadratic behaviour for large lists. -unionListsOrd :: (HasDebugCallStack, Outputable a, Ord a) => [a] -> [a] -> [a] +unionListsOrd :: Ord a => [a] -> [a] -> [a] unionListsOrd xs ys - -- Since both arguments don't have internal duplicates we can just take all of xs - -- and every element of ys that's not already in xs. + -- Since both arguments don't have internal duplicates we can just take all of ys + -- and every element of xs that's not already in ys. = let set_ys = S.fromList ys in (filter (\e -> not $ S.member e set_ys) xs) ++ ys +{-# INLINABLE unionListsOrd #-} -- Ensure the function can be specialized. -- | Assumes that the arguments contain no duplicates unionLists :: (HasDebugCallStack, Outputable a, Eq a) => [a] -> [a] -> [a] @@ -108,6 +109,7 @@ minusList xs [y] = filter (/= y) xs minusList xs ys = filter (`S.notMember` yss) xs where yss = S.fromList ys +{-# INLINABLE minusList #-} -- Ensure the function can be specialized. {- ************************************************************************ View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/092fcbbe8965e7f89b75a5e784695966... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/092fcbbe8965e7f89b75a5e784695966... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Simon Jakobi (@sjakobi2)