diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-18 20:54:35 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-18 20:54:35 +0200 |
| commit | cd554b0af706b5f62b4e1bfde04091052b4aac61 (patch) | |
| tree | e6d02f1c2a1da27da17386e8832c2d4a3e699cdf /internal/flamegraph/livetrie.go | |
| parent | b421b2232351049277ee4ad5b31367bb2b6779bb (diff) | |
cleanup
Diffstat (limited to 'internal/flamegraph/livetrie.go')
| -rw-r--r-- | internal/flamegraph/livetrie.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/flamegraph/livetrie.go b/internal/flamegraph/livetrie.go index 600e404..51f3697 100644 --- a/internal/flamegraph/livetrie.go +++ b/internal/flamegraph/livetrie.go @@ -1,10 +1,10 @@ package flamegraph import ( + "cmp" "encoding/json" "fmt" "slices" - "sort" "strings" "sync" "sync/atomic" @@ -277,8 +277,8 @@ type childSnapshotState struct { func buildSnapshotWithTotal(node *trieNode, depth int, minFraction float64, rootTotal uint64, forceKeep bool) (*trieSnapshot, uint64) { total := node.value children := slices.Clone(node.children) - sort.Slice(children, func(i, j int) bool { - return children[i].name < children[j].name + slices.SortFunc(children, func(a, b *trieNode) int { + return cmp.Compare(a.name, b.name) }) childStates := make([]childSnapshotState, 0, len(children)) @@ -335,13 +335,13 @@ func ensureFallbackVisibleChildren(children []childSnapshotState, depth int, min candidates = append(candidates, idx) } } - sort.Slice(candidates, func(i, j int) bool { - left := children[candidates[i]] - right := children[candidates[j]] - if left.total == right.total { - return left.node.name < right.node.name + slices.SortFunc(candidates, func(a, b int) int { + left := children[a] + right := children[b] + if left.total != right.total { + return cmp.Compare(right.total, left.total) } - return left.total > right.total + return cmp.Compare(left.node.name, right.node.name) }) limit := liveTrieMinVisibleChildrenWhenPruned |
