Skip to content

Commit 69664f7

Browse files
committed
Make unusedDataApply inline so that no closure is allocated.
It is used for every single tree in `CheckUnused`, so this is worth it.
1 parent b0d32aa commit 69664f7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ class CheckUnused private (phaseMode: CheckUnused.PhaseMode, suffix: String, _ke
4040
import CheckUnused.*
4141
import UnusedData.*
4242

43-
private def unusedDataApply[U](f: UnusedData => U)(using Context): Context =
44-
ctx.property(_key).foreach(f)
43+
private inline def unusedDataApply[U](inline f: UnusedData => U)(using Context): Context =
44+
ctx.property(_key) match
45+
case Some(ud) => f(ud)
46+
case None => ()
4547
ctx
4648

4749
override def phaseName: String = CheckUnused.phaseNamePrefix + suffix

0 commit comments

Comments
 (0)