summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2022-08-04 20:24:49 +0200
committerAndreas Klebinger <klebinger.andreas@gmx.at>2022-08-04 20:24:49 +0200
commitc661b8b34b0eceb4213205e4c20e74407878cfb4 (patch)
tree1f0b7d430f29469b637ee104771010123afd21e5
parent1d94a59fbadd56efec78680c89946eb425eef418 (diff)
downloadhaskell-wip/andreas/opt-tidy.tar.gz
findExternalRules: Don't needlessly traverse the list of rules.wip/andreas/opt-tidy
-rw-r--r--compiler/GHC/Iface/Tidy.hs7
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/GHC/Iface/Tidy.hs b/compiler/GHC/Iface/Tidy.hs
index 52a3291375..1edd3cb9bf 100644
--- a/compiler/GHC/Iface/Tidy.hs
+++ b/compiler/GHC/Iface/Tidy.hs
@@ -976,7 +976,8 @@ findExternalRules :: TidyOpts
findExternalRules opts binds imp_id_rules unfold_env
= (trimmed_binds, filter keep_rule all_rules)
where
- imp_rules = filter expose_rule imp_id_rules
+ imp_rules | (opt_expose_rules opts) = filter expose_rule imp_id_rules
+ | otherwise = []
imp_user_rule_fvs = mapUnionVarSet user_rule_rhs_fvs imp_rules
user_rule_rhs_fvs rule | isAutoRule rule = emptyVarSet
@@ -997,9 +998,7 @@ findExternalRules opts binds imp_id_rules unfold_env
-- RHS: the auto rules that might mention a binder that has
-- been discarded; see Note [Trimming auto-rules]
- expose_rule rule
- | not (opt_expose_rules opts) = False
- | otherwise = all is_external_id (ruleLhsFreeIdsList rule)
+ expose_rule rule = all is_external_id (ruleLhsFreeIdsList rule)
-- Don't expose a rule whose LHS mentions a locally-defined
-- Id that is completely internal (i.e. not visible to an
-- importing module). NB: ruleLhsFreeIds only returns LocalIds.