1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-10-28 15:02:28 +00:00

Apply more mechanical simplifications using recent Go features

This is a follow-up on the `go fix` run in commit
0210c5fd92.

That commit recorded the automated updates.

This one applies further simplifications that are mechanical and do not
involve logic changes, but are outside of what `go fix` did.

It also removes some now-obsolete comments and statements.
This commit is contained in:
Alberto Bertogli
2026-10-03 09:08:22 +01:00
parent 0210c5fd92
commit 8d763f450d
33 changed files with 99 additions and 161 deletions
+3 -3
View File
@@ -8,7 +8,7 @@ import (
"html/template"
"math"
"net/http"
"sort"
"slices"
"strconv"
"time"
)
@@ -156,8 +156,8 @@ func allEvents(tr *trace) []traceAndEvent {
evts := appendAllEvents(tr, []traceAndEvent{}, seen, 0)
// Sort them by time.
sort.Slice(evts, func(i, j int) bool {
return evts[i].Event.When.Before(evts[j].Event.When)
slices.SortFunc(evts, func(a, b traceAndEvent) int {
return a.Event.When.Compare(b.Event.When)
})
return evts
+7 -14
View File
@@ -7,7 +7,7 @@ import (
"fmt"
"maps"
"math/rand/v2"
"sort"
"slices"
"strconv"
"strings"
"sync"
@@ -29,11 +29,8 @@ func newID(family string, ts int64) id {
}
func (id id) Family() string {
sp := strings.SplitN(string(id), "!", 2)
if len(sp) != 2 {
return string(id)
}
return sp[0]
family, _, _ := strings.Cut(string(id), "!")
return family
}
// Trace represents a single request trace.
@@ -433,8 +430,8 @@ func (ft *familyTraces) TracesFor(b int, allgt bool) []*trace {
// Sort them by start, newer first. This is the order that will be used
// when displaying them.
sort.Slice(trs, func(i, j int) bool {
return trs[i].Start.After(trs[j].Start)
slices.SortFunc(trs, func(a, b *trace) int {
return b.Start.Compare(a.Start)
})
return trs
}
@@ -510,13 +507,9 @@ var (
)
func copyFamilies() map[string]*familyTraces {
n := map[string]*familyTraces{}
familiesMu.Lock()
maps.Copy(n, families)
familiesMu.Unlock()
return n
defer familiesMu.Unlock()
return maps.Clone(families)
}
func findInFamilies(traceID id, refID id) *trace {