diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2022-03-11 15:48:15 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-03-12 07:03:56 -0500 |
commit | 88a945410fe613d41fa3778b71fc187c6ec90155 (patch) | |
tree | 32a88dcf6313014e6131d8f2a0e77d26c9063ab4 /hadrian/src | |
parent | 7fe0714326080540945fb780cdf65e90e4b49d2f (diff) | |
download | haskell-88a945410fe613d41fa3778b71fc187c6ec90155.tar.gz |
Hadrian: avoid useless allocations in trackArgument
Cf ticky report before the change:
Entries Alloc Alloc'd Non-void Arguments STG Name
--------------------------------------------------------------------------------
696987 29044128 0 1 L main:Target.trackArgument_go5{v r24kY} (fun)
Diffstat (limited to 'hadrian/src')
-rw-r--r-- | hadrian/src/Target.hs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/hadrian/src/Target.hs b/hadrian/src/Target.hs index 07a31fc464..3655cd5047 100644 --- a/hadrian/src/Target.hs +++ b/hadrian/src/Target.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE LambdaCase #-} + module Target ( Target, target, context, builder, inputs, outputs, trackArgument, module Builder @@ -25,8 +27,14 @@ trackArgument target arg = case builder target of Cabal _ _ -> not $ verbosityArg arg || cabal_configure_ignore arg _ -> True where - threadArg s = dropWhileEnd isDigit s `elem` ["-j", "MAKEFLAGS=-j", "THREADS="] - verbosityArg s = dropWhileEnd isDigit s == "-v" + match_str_num [] rs = all isDigit rs + match_str_num (x:xs) (r:rs) = x == r && match_str_num xs rs + match_str_num (_:_) [] = False + + threadArg s = match_str_num "-j" s || match_str_num "MAKEFLAGS=-j" s || match_str_num "THREADS=" s + verbosityArg s = match_str_num "-v" s diagnosticsColorArg s = "-fdiagnostics-color=" `isPrefixOf` s -- N.B. #18672 - cabal_configure_ignore s = - s `elem` [ "--configure-option=--quiet", "--configure-option=--disable-option-checking" ] + cabal_configure_ignore = \case + "--configure-option=--quiet" -> True + "--configure-option=--disable-option-checking" -> True + _ -> False |