on main help sign in
perf(ansiext): grow string builder to optimize allocations
e6186c6Andrey Nering
internal/ansiext/ansi.go+1
@@ -10,6 +10,7 @@ import (
10// representations to ensure they are displayed correctly in the UI.
10// representations to ensure they are displayed correctly in the UI.
11func Escape(content string) string {
11func Escape(content string) string {
12 var sb strings.Builder
12 var sb strings.Builder
13+ sb.Grow(len(content))
13 for _, r := range content {
14 for _, r := range content {
14 switch {
15 switch {
15 case r >= 0 && r <= 0x1f: // Control characters 0x00-0x1F
16 case r >= 0 && r <= 0x1f: // Control characters 0x00-0x1F