Commit bb12a1bc by Mario Trangoni

pkg/tsdb/graphite/graphite.go: Fix regular expression does not contain any meta characters.

I found this article benchmarking Replace vs Regexp,
https://medium.com/codezillas/golang-replace-vs-regexp-de4e48482f53

See,
$ gometalinter --vendor --deadline 10m --disable-all --enable=megacheck ./...
pkg/tsdb/graphite/graphite.go:167:28:warning: regular expression does not contain any meta characters (SA6004) (megacheck)
pkg/tsdb/graphite/graphite.go:172:28:warning: regular expression does not contain any meta characters (SA6004) (megacheck)
parent 3466969a
......@@ -164,14 +164,12 @@ func formatTimeRange(input string) string {
func fixIntervalFormat(target string) string {
rMinute := regexp.MustCompile(`'(\d+)m'`)
rMin := regexp.MustCompile("m")
target = rMinute.ReplaceAllStringFunc(target, func(m string) string {
return rMin.ReplaceAllString(m, "min")
return strings.Replace(m, "m", "min", -1)
})
rMonth := regexp.MustCompile(`'(\d+)M'`)
rMon := regexp.MustCompile("M")
target = rMonth.ReplaceAllStringFunc(target, func(M string) string {
return rMon.ReplaceAllString(M, "mon")
return strings.Replace(M, "M", "mon", -1)
})
return target
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment