diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-02-23 17:45:51 +0000 |
---|---|---|
committer | Ben Gamari <ben@well-typed.com> | 2021-04-02 18:13:11 -0400 |
commit | 0cb84d0e2538c7c7a493c7aa7eaaecbb7996b6ef (patch) | |
tree | 615125117e9cf7fa2c85aa47525b4ea8bb43ffe8 | |
parent | ce706faeef3964116c6e1dd0e6ae2f2e77fde57d (diff) | |
download | haskell-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.hs | 2 |
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. |