diff --git a/tools/cmd/diff/collect.go b/tools/cmd/diff/collect.go index 171f424dc..cf52ffc9e 100644 --- a/tools/cmd/diff/collect.go +++ b/tools/cmd/diff/collect.go @@ -104,7 +104,9 @@ func hash_for_path(path string) (string, error) { } func sanitize_control_codes(x string) string { - return utils.SanitizeControlCodes(x, "░") + // exclude newlines, carriage returns and tabs + pat := utils.MustCompile("[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\u0080-\u009f]") + return pat.ReplaceAllLiteralString(x, "░") } func sanitize_tabs_and_carriage_returns(x string) string { diff --git a/tools/utils/misc.go b/tools/utils/misc.go index 8d11c0248..6e523cb0b 100644 --- a/tools/utils/misc.go +++ b/tools/utils/misc.go @@ -4,7 +4,6 @@ package utils import ( "fmt" - "regexp" "sort" "golang.org/x/exp/constraints" @@ -152,15 +151,3 @@ func Memset[T any](dest []T, pattern ...T) []T { } return dest } - -var ControlCodesPat = (&Once[*regexp.Regexp]{Run: func() *regexp.Regexp { - return regexp.MustCompile("[\x00-\x09\x0b-\x1f\x7f\u0080-\u009f]") -}}).Get - -func SanitizeControlCodes(raw string, replace_with ...string) string { - r := "" - if len(replace_with) > 0 { - r = replace_with[0] - } - return ControlCodesPat().ReplaceAllLiteralString(raw, r) -}