Skip to content

Commit d92e3e6

Browse files
committed
Avoid creating unnecessary new lists in mapArgs
1 parent 9dfdeec commit d92e3e6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3833,12 +3833,14 @@ object Types {
38333833

38343834
case tp: AppliedType =>
38353835
def mapArgs(args: List[Type], tparams: List[ParamInfo]): List[Type] = args match {
3836-
case arg :: args1 =>
3836+
case arg :: otherArgs =>
38373837
val arg1 = arg match {
38383838
case arg: TypeBounds => this(arg)
38393839
case arg => atVariance(variance * tparams.head.paramVariance)(this(arg))
38403840
}
3841-
arg1 :: mapArgs(args1, tparams.tail)
3841+
val otherArgs1 = mapArgs(otherArgs, tparams.tail)
3842+
if ((arg1 eq arg) && (otherArgs1 eq otherArgs)) args
3843+
else arg1 :: otherArgs1
38423844
case nil =>
38433845
nil
38443846
}

0 commit comments

Comments
 (0)