Skip to content

Commit aadab27

Browse files
committed
Performance tweeak
1 parent c148484 commit aadab27

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
@@ -298,9 +298,14 @@ object NameOps {
298298
* `<return type><first type><second type><...>`
299299
*/
300300
def specializedFunction(ret: Type, args: List[Type])(using Context): Name =
301-
name ++ nme.specializedTypeNames.prefix ++
302-
nme.specializedTypeNames.separator ++ defn.typeTag(ret) ++
303-
args.map(defn.typeTag).fold(nme.EMPTY)(_ ++ _) ++ nme.specializedTypeNames.suffix
301+
val sb = new StringBuffer
302+
sb.append(name.toString)
303+
sb.append(nme.specializedTypeNames.prefix.toString)
304+
sb.append(nme.specializedTypeNames.separator)
305+
sb.append(defn.typeTag(ret).toString)
306+
args.foreach { arg => sb.append(defn.typeTag(arg)) }
307+
sb.append(nme.specializedTypeNames.suffix)
308+
termName(sb.toString)
304309

305310
/** If name length exceeds allowable limit, replace part of it by hash */
306311
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)