From cd554b0af706b5f62b4e1bfde04091052b4aac61 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 18 Mar 2026 20:54:35 +0200 Subject: cleanup --- internal/flamegraph/livetrie.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'internal/flamegraph/livetrie.go') 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 -- cgit v1.2.3