Skip to content

Commit 1fe3ba7

Browse files
committed
Use common name buffer for more name creation ops
1 parent 1fd0844 commit 1fe3ba7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import scala.internal.Chars.isIdentifierStart
1111
import collection.immutable
1212
import config.Config
1313
import java.util.HashMap
14+
import Contexts.Context
1415

1516
import scala.annotation.internal.sharable
1617

@@ -638,13 +639,8 @@ object Names {
638639
def typeName(bs: Array[Byte], offset: Int, len: Int): TypeName =
639640
termName(bs, offset, len).toTypeName
640641

641-
/** Create a term name from a string, without encoding operators */
642-
def termName(s: String): SimpleName = termName(s.toCharArray, 0, s.length)
643-
644-
/** Create a type name from a string, without encoding operators */
645-
def typeName(s: String): TypeName = typeName(s.toCharArray, 0, s.length)
646-
647-
def termName(s: String, from: Int, len: Int)(using ctx: Contexts.Context): TermName = {
642+
/** Create a term name from a string slice */
643+
def termName(s: String, from: Int, len: Int)(using Context): SimpleName = {
648644
val base = ctx.base
649645

650646
while (len > base.nameCharBuffer.length)
@@ -654,9 +650,16 @@ object Names {
654650
termName(base.nameCharBuffer, 0, len)
655651
}
656652

657-
def typeName(s: String, from: Int, len: Int)(using ctx: Contexts.Context): TypeName =
653+
/** Create a type name from a string slice */
654+
def typeName(s: String, from: Int, len: Int)(using Context): TypeName =
658655
termName(s, from, len).toTypeName
659656

657+
/** Create a term name from a string, */
658+
def termName(s: String): SimpleName = termName(s, 0, s.length)
659+
660+
/** Create a type name from a string */
661+
def typeName(s: String): TypeName = typeName(s, 0, s.length)
662+
660663
table(0) = new SimpleName(-1, 0, null)
661664

662665
/** The term name represented by the empty string */

0 commit comments

Comments
 (0)