From a33568d3d2a330236a631e2f9bd350c6794d2ebb Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Fri, 4 Nov 2022 18:03:14 +0100 Subject: [PATCH] Add locking Maybe not needed. --- m/ansiTokenizer.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/m/ansiTokenizer.go b/m/ansiTokenizer.go index b0e2136..80b5806 100644 --- a/m/ansiTokenizer.go +++ b/m/ansiTokenizer.go @@ -6,6 +6,7 @@ import ( "regexp" "strconv" "strings" + "sync" "unicode" log "github.com/sirupsen/logrus" @@ -116,6 +117,7 @@ func isPlain(s string) bool { // // Interface mimics strings.Builder. var stripped reusableStringBuilder +var strippedLock sync.Mutex // FIXME: Try removing this and see if we still work // NOTE: Uses a global "stripped" variable for performance. If you start calling // this from multiple threads at the same time it will break. @@ -124,6 +126,9 @@ func withoutFormatting(s string) string { return s } + strippedLock.Lock() + defer strippedLock.Unlock() + runeCount := 0 stripped.Reset()