Commit e0bb4c95 authored by zauberstuhl's avatar zauberstuhl
Browse files

Optimize regexp and map loop

parent b3cd12c7
Pipeline #765 passed with stage
in 1 minute and 17 seconds
...@@ -83,17 +83,20 @@ func reportsBadge(fqdn, slug string, w http.ResponseWriter, r *http.Request) { ...@@ -83,17 +83,20 @@ func reportsBadge(fqdn, slug string, w http.ResponseWriter, r *http.Request) {
} }
var success, fail, skip int var success, fail, skip int
reSkip := regexp.MustCompile(`^ok.*#\sskip`)
reOk := regexp.MustCompile(`^ok`)
reNot := regexp.MustCompile(`^not`)
for _, report := range reports { for _, report := range reports {
for _, line := range strings.Split(report, "\n") { for _, line := range strings.Split(report, "\n") {
if m, err := regexp.MatchString(`^ok.*#\sskip`, line); m && err == nil { if reSkip.MatchString(line) {
skip += 1 skip += 1
continue continue
} }
if m, err := regexp.MatchString(`^ok`, line); m && err == nil { if reOk.MatchString(line) {
success += 1 success += 1
continue continue
} }
if m, err := regexp.MatchString(`^not`, line); m && err == nil { if reNot.MatchString(line) {
fail += 1 fail += 1
continue continue
} }
......
...@@ -78,7 +78,7 @@ func buildsPNG(w http.ResponseWriter, r *http.Request) { ...@@ -78,7 +78,7 @@ func buildsPNG(w http.ResponseWriter, r *http.Request) {
// sort // sort
var keys sortTime var keys sortTime
for key, _ := range statesPerDay { for key := range statesPerDay {
keys = append(keys, key) keys = append(keys, key)
} }
sort.Sort(keys) sort.Sort(keys)
......
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