Util: Improve performance of strings.SplitString (#49115) (#49654)

Replaces the regexp with calls to strings.ReplaceAll and strings.Fields
for simplicity and improved performance.

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
(cherry picked from commit 1f85101787)

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2022-05-25 23:22:50 +02:00
committed by GitHub
co-authored by Dave Henderson
parent 1a69cc5b21
commit 0726a56956
2 changed files with 48 additions and 2 deletions
+1 -2
View File
@@ -3,7 +3,6 @@ package util
import (
"fmt"
"math"
"regexp"
"strings"
"time"
"unicode"
@@ -34,7 +33,7 @@ func SplitString(str string) []string {
return []string{}
}
return regexp.MustCompile("[, ]+").Split(str, -1)
return strings.Fields(strings.ReplaceAll(str, ",", " "))
}
// GetAgeString returns a string representing certain time from years to minutes.