Skip to content

Commit f647585

Browse files
committed
Performance tweeak
1 parent 1b971b8 commit f647585

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,14 @@ object NameOps {
294294
* `<return type><first type><second type><...>`
295295
*/
296296
def specializedFunction(ret: Type, args: List[Type])(using Context): Name =
297-
name ++ nme.specializedTypeNames.prefix ++
298-
nme.specializedTypeNames.separator ++ defn.typeTag(ret) ++
299-
args.map(defn.typeTag).fold(nme.EMPTY)(_ ++ _) ++ nme.specializedTypeNames.suffix
297+
val sb = new StringBuffer
298+
sb.append(name.toString)
299+
sb.append(nme.specializedTypeNames.prefix.toString)
300+
sb.append(nme.specializedTypeNames.separator)
301+
sb.append(defn.typeTag(ret).toString)
302+
args.foreach { arg => sb.append(defn.typeTag(arg)) }
303+
sb.append(nme.specializedTypeNames.suffix)
304+
termName(sb.toString)
300305

301306
/** If name length exceeds allowable limit, replace part of it by hash */
302307
def compactified(using Context): TermName = termName(compactify(name.toString))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ class SpecializeApplyMethods extends MiniPhase with InfoTransformer {
7171

7272
else if sym == defn.SpecializableFunctions(1) then
7373
val scope = tp.decls.cloneScope
74-
specFun1 { (t1, r) => scope.enter(specApplySymbol(sym, List(t1), r)) }
74+
specFun1 { (t1, r) => scope.enter(specApplySymbol(sym, t1 :: Nil, r)) }
7575
tp.derivedClassInfo(decls = scope)
7676

7777
else if sym == defn.SpecializableFunctions(2) then
7878
val scope = tp.decls.cloneScope
79-
specFun2 { (t1, t2, r) => scope.enter(specApplySymbol(sym, List(t1, t2), r)) }
79+
specFun2 { (t1, t2, r) => scope.enter(specApplySymbol(sym, t1 :: t2 :: Nil, r)) }
8080
tp.derivedClassInfo(decls = scope)
8181

8282
else tp

0 commit comments

Comments
 (0)