Skip to content

Commit 26e49de

Browse files
committed
Eliminate closure in foreachTypeVar
It's fairly hot code, and eliminating the closure also avoids Int boxing.
1 parent 6f5dba1 commit 26e49de

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,13 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
567567

568568
def foreachTypeVar(op: TypeVar => Unit): Unit =
569569
boundsMap.foreachBinding { (poly, entries) =>
570-
for (i <- 0 until paramCount(entries))
571-
typeVar(entries, i) match {
570+
var i = 0
571+
val limit = paramCount(entries)
572+
while i < limit do
573+
typeVar(entries, i) match
572574
case tv: TypeVar if !tv.inst.exists => op(tv)
573575
case _ =>
574-
}
576+
i += 1
575577
}
576578

577579
private var myUninstVars: mutable.ArrayBuffer[TypeVar] = _

0 commit comments

Comments
 (0)