From 89acbf356b1e1c09cb1cd123f56ab5f3ad6d0634 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Tue, 23 Feb 2021 17:45:51 +0000 Subject: 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. --- compiler/GHC/Stg/Syntax.hs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'compiler/GHC/Stg') 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. -- cgit v1.2.1