File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package core
3
3
4
4
import scala .collection .mutable
5
5
import scala .annotation .switch
6
+ import scala .annotation .internal .sharable
6
7
import Names ._
7
8
import Symbols ._
8
9
import Contexts ._
@@ -40,7 +41,9 @@ object StdNames {
40
41
inline val Tuple = " Tuple"
41
42
inline val Product = " Product"
42
43
43
- def sanitize (str : String ): String = str.replaceAll(""" [<>]""" , """ \$""" ).nn
44
+ @ sharable
45
+ private val disallowed = java.util.regex.Pattern .compile(""" [<>]""" ).nn
46
+ def sanitize (str : String ): String = disallowed.matcher(str).nn.replaceAll(""" \$""" ).nn
44
47
}
45
48
46
49
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