Skip to content

Commit b7e51db

Browse files
committed
Do not initialize the Simplifier if it will not transform
1 parent 58fe948 commit b7e51db

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

compiler/src/dotty/tools/dotc/transform/localopt/Simplify.scala

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,19 @@ class Simplify extends MiniPhase with IdentityDenotTransformer {
7979
var fuel: Int = -1
8080

8181
override def prepareForUnit(tree: Tree)(implicit ctx: Context) = {
82-
SeqFactoryClass = ctx.requiredClass("scala.collection.generic.SeqFactory")
83-
CommutativePrimitiveOperations = Set(defn.Boolean_&&, defn.Boolean_||, defn.Int_+, defn.Int_*, defn.Long_+, defn.Long_*)
84-
85-
val maxFuel = ctx.settings.YoptFuel.value
86-
if (fuel < 0 && maxFuel > 0) // Both defaults are at -1
87-
fuel = maxFuel
88-
89-
optimisations = {
90-
val o = if (ctx.erasedTypes) afterErasure else beforeErasure
91-
val p = ctx.settings.YoptPhases.value
92-
if (p.isEmpty) o else o.filter(x => p.contains(x.name))
82+
if (ctx.settings.optimise.value) {
83+
SeqFactoryClass = ctx.requiredClass("scala.collection.generic.SeqFactory")
84+
CommutativePrimitiveOperations = Set(defn.Boolean_&&, defn.Boolean_||, defn.Int_+, defn.Int_*, defn.Long_+, defn.Long_*)
85+
86+
val maxFuel = ctx.settings.YoptFuel.value
87+
if (fuel < 0 && maxFuel > 0) // Both defaults are at -1
88+
fuel = maxFuel
89+
90+
optimisations = {
91+
val o = if (ctx.erasedTypes) afterErasure else beforeErasure
92+
val p = ctx.settings.YoptPhases.value
93+
if (p.isEmpty) o else o.filter(x => p.contains(x.name))
94+
}
9395
}
9496

9597
ctx

0 commit comments

Comments
 (0)