File tree 2 files changed +5
-2
lines changed
compiler/src/dotty/tools/dotc
2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,8 @@ object StdNames {
40
40
inline val Tuple = " Tuple"
41
41
inline val Product = " Product"
42
42
43
- def sanitize (str : String ): String = str.replaceAll(""" [<>]""" , """ \$""" ).nn
43
+ private val disallowed = java.util.regex.Pattern .compile(""" [<>]""" ).nn
44
+ def sanitize (str : String ): String = disallowed.matcher(str).nn.replaceAll(""" \$""" ).nn
44
45
}
45
46
46
47
abstract class DefinedNames [N <: Name ] {
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package printing
3
3
4
4
object Texts {
5
5
6
+ private val ansi = java.util.regex.Pattern .compile(" \u001b\\ [\\ d+m" ).nn
7
+
6
8
sealed abstract class Text {
7
9
8
10
protected def indentMargin : Int = 2
@@ -70,7 +72,7 @@ object Texts {
70
72
else appendIndented(that)(width)
71
73
72
74
private def lengthWithoutAnsi (str : String ): Int =
73
- str. replaceAll(" \u001b\\ [ \\ d+m " , " " ).nn.length
75
+ ansi.matcher( str).nn. replaceAll(" " ).nn.length
74
76
75
77
def layout (width : Int ): Text = this match {
76
78
case Str (s, _) =>
You can’t perform that action at this time.
0 commit comments