@@ -8,6 +8,7 @@ import scala.io.Codec
88import Int .MaxValue
99import Names ._ , StdNames ._ , Contexts ._ , Symbols ._ , Flags ._ , NameKinds ._ , Types ._
1010import util .Chars .{isOperatorPart , digit2int }
11+ import Decorators .*
1112import Definitions ._
1213import nme ._
1314
@@ -278,16 +279,20 @@ object NameOps {
278279 classTags.fold(nme.EMPTY )(_ ++ _) ++ nme.specializedTypeNames.suffix)
279280 }
280281
282+ /** Determines if the current name is the specialized name of the given base name.
283+ * For example `typeName("Tuple2$mcII$sp").isSpecializedNameOf(tpnme.Tuple2) == true`
284+ */
281285 def isSpecializedNameOf (base : N )(using Context ): Boolean =
282- import Decorators .*
283- val sb = new StringBuilder
284- sb.append(base.toString)
285- sb.append(nme.specializedTypeNames.prefix.toString)
286- sb.append(nme.specializedTypeNames.separator)
287- val prefix = sb.toString()
288- val suffix = nme.specializedTypeNames.suffix.toString
289- name.startsWith(prefix) && name.endsWith(suffix)
290-
286+ var i = 0
287+ inline def nextString (str : String ) = name.startsWith(str, i) && { i += str.length; true }
288+ nextString(base.toString)
289+ && nextString(nme.specializedTypeNames.prefix.toString)
290+ && nextString(nme.specializedTypeNames.separator.toString)
291+ && name.endsWith(nme.specializedTypeNames.suffix.toString)
292+
293+ /** Returns the name of the class specialised to the provided types,
294+ * in the given order. Used for the specialized tuple classes.
295+ */
291296 def specializedName (args : List [Type ])(using Context ): N =
292297 val sb = new StringBuilder
293298 sb.append(name.toString)
0 commit comments