@@ -11,6 +11,7 @@ import scala.internal.Chars.isIdentifierStart
1111import collection .immutable
1212import config .Config
1313import java .util .HashMap
14+ import Contexts .{Context , ctx }
1415
1516import scala .annotation .internal .sharable
1617
@@ -638,12 +639,18 @@ 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+ /** Create a term name from a string.
643+ * See `termName(s: String, from: Int, len: Int) for a more efficient version
644+ * which however requires a Context for its operation
645+ */
642646 def termName (s : String ): SimpleName = termName(s.toCharArray, 0 , s.length)
643647
644- /** Create a type name from a string, without encoding operators */
648+ /** Create a type name from a string */
645649 def typeName (s : String ): TypeName = typeName(s.toCharArray, 0 , s.length)
646650
651+ /** Create a term name from a string slice, using a common buffer.
652+ * This avoids some allocation relative to `termName(s: String)`
653+ */
647654 def termName (s : String , from : Int , len : Int )(using ctx : Contexts .Context ): TermName = {
648655 val base = ctx.base
649656
@@ -654,7 +661,10 @@ object Names {
654661 termName(base.nameCharBuffer, 0 , len)
655662 }
656663
657- def typeName (s : String , from : Int , len : Int )(using ctx : Contexts .Context ): TypeName =
664+ /** Create a type name from a string slice, using a common buffer.
665+ * This avoids some allocation relative to `typeName(s: String)`
666+ */
667+ def typeName (s : String , from : Int , len : Int )(using Context ): TypeName =
658668 termName(s, from, len).toTypeName
659669
660670 table(0 ) = new SimpleName (- 1 , 0 , null )
0 commit comments