summaryrefslogtreecommitdiff
path: root/compiler/GHC/Stg
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-02-23 17:45:51 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-04-05 20:38:42 -0400
commit89acbf356b1e1c09cb1cd123f56ab5f3ad6d0634 (patch)
tree504d265101deef310d8f3999446baa29750ffbe4 /compiler/GHC/Stg
parent9c9adbd0ffe6ecc37d3a565811d8e79f24383943 (diff)
downloadhaskell-89acbf356b1e1c09cb1cd123f56ab5f3ad6d0634.tar.gz
Add special case to stripStgTicksTop for []
In the common case where the list of ticks is empty, building a thunk just applies 'reverse' to '[]' which is quite wasteful.
Diffstat (limited to 'compiler/GHC/Stg')
-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.