This is an automated email from the ASF dual-hosted git repository. sruehl pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit a97260fd866111626ee1af8d43ac526f61a2ce79 Author: Sebastian Rühl <[email protected]> AuthorDate: Thu Nov 20 12:23:09 2025 +0100 perf(plc4go/spi): avoid frequent recompile of ascii regex --- plc4go/spi/utils/asciiBox.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plc4go/spi/utils/asciiBox.go b/plc4go/spi/utils/asciiBox.go index dc2e3edde6..7a42cf919b 100644 --- a/plc4go/spi/utils/asciiBox.go +++ b/plc4go/spi/utils/asciiBox.go @@ -488,10 +488,14 @@ func countChars(s string) int { return len([]rune(ANSI_PATTERN.ReplaceAllString(s, ""))) } +var controlStripRegex = regexp.MustCompile(`\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])`) + // cleanString returns the strings minus the control sequences func cleanString(s string) string { - regex, _ := regexp.Compile(`\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])`) - return regex.ReplaceAllString(s, "") + if s == "" { + return s + } + return controlStripRegex.ReplaceAllString(s, "") } //
