8000 Avoid repeating call to Symbol#typeParams in hot code · scala/scala@b9ea9b4 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit b9ea9b4

Browse files
committed
Avoid repeating call to Symbol#typeParams in hot code
1 parent f793b99 commit b9ea9b4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/reflect/scala/reflect/internal/tpe/TypeMaps.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,16 @@ private[internal] trait TypeMaps {
101101
case tr @ TypeRef(pre, sym, args) =>
102102
val pre1 = this(pre)
103103
val args1 = (
104-
if (trackVariance && args.nonEmpty && !variance.isInvariant && sym.typeParams.nonEmpty)
105-
mapOverArgs(args, sym.typeParams)
106-
else
104+
if (trackVariance && args.nonEmpty && !variance.isInvariant) {
105+
val tparams = sym.typeParams
106+
if (tparams.isEmpty)
107+
args mapConserve this
108+
else
109+
mapOverArgs(args, tparams)
110+
} else {
107111
args mapConserve this
108-
)
112+
}
113+
)
109114
if ((pre1 eq pre) && (args1 eq args)) tp
110115
else copyTypeRef(tp, pre1, tr.coevolveSym(pre1), args1)
111116
case ThisType(_) => tp

0 commit comments

Comments
 (0)
0