mirror of
https://github.com/walles/moar.git
synced 2024-10-26 13:00:40 +03:00
Add locking
Maybe not needed.
This commit is contained in:
parent
78344d1761
commit
a33568d3d2
@ -6,6 +6,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@ -116,6 +117,7 @@ func isPlain(s string) bool {
|
|||||||
//
|
//
|
||||||
// Interface mimics strings.Builder.
|
// Interface mimics strings.Builder.
|
||||||
var stripped reusableStringBuilder
|
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
|
// NOTE: Uses a global "stripped" variable for performance. If you start calling
|
||||||
// this from multiple threads at the same time it will break.
|
// this from multiple threads at the same time it will break.
|
||||||
@ -124,6 +126,9 @@ func withoutFormatting(s string) string {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strippedLock.Lock()
|
||||||
|
defer strippedLock.Unlock()
|
||||||
|
|
||||||
runeCount := 0
|
runeCount := 0
|
||||||
stripped.Reset()
|
stripped.Reset()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user