diff options
author | Gabor Greif <ggreif@gmail.com> | 2019-12-14 19:07:32 +0100 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2019-12-14 19:29:59 +0100 |
commit | a5bf7fafa8700336c22d1ec3d1d2da78ffe8126b (patch) | |
tree | 2127ac5adb2a149cbf6280ba3c246b8bd94a13f8 | |
parent | 7179b968c709eb0f5413c8e3847a8a593c596185 (diff) | |
download | haskell-wip/T14373.tar.gz |
use frugal partitionwip/T14373
-rw-r--r-- | compiler/GHC/StgToCmm/Expr.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler/GHC/StgToCmm/Expr.hs b/compiler/GHC/StgToCmm/Expr.hs index 38d35fc031..62c404384e 100644 --- a/compiler/GHC/StgToCmm/Expr.hs +++ b/compiler/GHC/StgToCmm/Expr.hs @@ -51,7 +51,6 @@ import Outputable import Control.Monad ( unless, void ) import Control.Arrow ( first ) -import Data.List ( partition ) ------------------------------------------------------------------------ -- cgExpr: the main function @@ -602,6 +601,15 @@ chooseReturnBndrs bndr PolyAlt _alts chooseReturnBndrs _ _ _ = panic "chooseReturnBndrs" -- MultiValAlt has only one alternative +-- space conscious partition +partition_ :: (a -> Bool) -> [a] -> ([a], [a]) +partition_ _ [] = ([], []) +partition_ p l@(a : as) + | (y, n) <- partition_ p as = + if p a + then (if null n then l else a : y, n) + else (y, if null y then l else a : n) + ------------------------------------- cgAlts :: (GcPlan,ReturnKind) -> NonVoid Id -> AltType -> [CgStgAlt] -> FCode ReturnKind @@ -638,7 +646,7 @@ cgAlts gc_plan bndr (AlgAlt tycon) alts !ptag_expr = cmmConstrTag1 dflags (CmmReg bndr_reg) !branches' = first succ <$> branches !maxpt = mAX_PTR_TAG dflags - (!via_ptr, !via_info) = partition ((< maxpt) . fst) branches' + (!via_ptr, !via_info) = partition_ ((< maxpt) . fst) branches' !small = isSmallFamily dflags fam_sz -- Is the constructor tag in the node reg? |