summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-02-23 17:45:51 +0000
committerBen Gamari <ben@well-typed.com>2021-04-02 18:13:11 -0400
commit0cb84d0e2538c7c7a493c7aa7eaaecbb7996b6ef (patch)
tree615125117e9cf7fa2c85aa47525b4ea8bb43ffe8
parentce706faeef3964116c6e1dd0e6ae2f2e77fde57d (diff)
downloadhaskell-wip/strip-ticks.tar.gz
Add special case to stripStgTicksTop for []wip/strip-ticks
In the common case where the list of ticks is empty, building a thunk just applies 'reverse' to '[]' which is quite wasteful.
-rw-r--r--compiler/GHC/Stg/Syntax.hs2
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/GHC/Stg/Syntax.hs b/compiler/GHC/Stg/Syntax.hs
index 972efc5f44..abbf4131d7 100644
--- a/compiler/GHC/Stg/Syntax.hs
+++ b/compiler/GHC/Stg/Syntax.hs
@@ -180,6 +180,8 @@ stgArgType (StgLitArg lit) = literalType lit
stripStgTicksTop :: (StgTickish -> Bool) -> GenStgExpr p -> ([StgTickish], GenStgExpr p)
stripStgTicksTop p = go []
where go ts (StgTick t e) | p t = go (t:ts) e
+ -- This special case avoid building a thunk for "reverse ts" when there are no ticks
+ go [] other = ([], other)
go ts other = (reverse ts, other)
-- | Strip ticks of a given type from an STG expression returning only the expression.