summaryrefslogtreecommitdiff
path: root/internal/tui/dashboard
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-18 20:54:35 +0200
committerPaul Buetow <paul@buetow.org>2026-03-18 20:54:35 +0200
commitcd554b0af706b5f62b4e1bfde04091052b4aac61 (patch)
treee6d02f1c2a1da27da17386e8832c2d4a3e699cdf /internal/tui/dashboard
parentb421b2232351049277ee4ad5b31367bb2b6779bb (diff)
cleanup
Diffstat (limited to 'internal/tui/dashboard')
-rw-r--r--internal/tui/dashboard/bubbles.go19
-rw-r--r--internal/tui/dashboard/files.go10
-rw-r--r--internal/tui/dashboard/icicle.go15
-rw-r--r--internal/tui/dashboard/treemap.go27
4 files changed, 37 insertions, 34 deletions
diff --git a/internal/tui/dashboard/bubbles.go b/internal/tui/dashboard/bubbles.go
index e6e2909..f50eba8 100644
--- a/internal/tui/dashboard/bubbles.go
+++ b/internal/tui/dashboard/bubbles.go
@@ -1,11 +1,12 @@
package dashboard
import (
+ "cmp"
"fmt"
"hash/fnv"
"image/color"
"math"
- "sort"
+ "slices"
"strings"
"unicode/utf8"
@@ -422,8 +423,8 @@ func (c *bubbleChart) renderBubblesToGrid(grid [][]bubbleCell, width, height int
for idx := range c.nodes {
order = append(order, idx)
}
- sort.Slice(order, func(i, j int) bool {
- return c.nodes[order[i]].radius < c.nodes[order[j]].radius
+ slices.SortFunc(order, func(a, b int) int {
+ return cmp.Compare(c.nodes[a].radius, c.nodes[b].radius)
})
if c.selected >= 0 && c.selected < len(c.nodes) {
filtered := order[:0]
@@ -641,13 +642,13 @@ func buildBubbleTargets(data []bubbleDatum, metric bubbleMetric, width, height i
if len(filtered) == 0 {
return nil
}
- sort.Slice(filtered, func(i, j int) bool {
- vi := bubbleValue(filtered[i], metric)
- vj := bubbleValue(filtered[j], metric)
- if vi != vj {
- return vi > vj
+ slices.SortFunc(filtered, func(a, b bubbleDatum) int {
+ va := bubbleValue(a, metric)
+ vb := bubbleValue(b, metric)
+ if va != vb {
+ return cmp.Compare(vb, va)
}
- return filtered[i].Label < filtered[j].Label
+ return cmp.Compare(a.Label, b.Label)
})
if len(filtered) > bubbleMaxItems {
filtered = filtered[:bubbleMaxItems]
diff --git a/internal/tui/dashboard/files.go b/internal/tui/dashboard/files.go
index f24c87c..df850ab 100644
--- a/internal/tui/dashboard/files.go
+++ b/internal/tui/dashboard/files.go
@@ -1,9 +1,9 @@
package dashboard
import (
+ "cmp"
"path/filepath"
"slices"
- "sort"
"strconv"
"ior/internal/statsengine"
@@ -425,11 +425,11 @@ func aggregateFilesByDir(files []statsengine.FileSnapshot) []DirSnapshot {
out = append(out, s)
}
- sort.Slice(out, func(i, j int) bool {
- if out[i].Accesses != out[j].Accesses {
- return out[i].Accesses > out[j].Accesses
+ slices.SortFunc(out, func(a, b DirSnapshot) int {
+ if a.Accesses != b.Accesses {
+ return cmp.Compare(b.Accesses, a.Accesses)
}
- return out[i].Dir < out[j].Dir
+ return cmp.Compare(a.Dir, b.Dir)
})
return out
}
diff --git a/internal/tui/dashboard/icicle.go b/internal/tui/dashboard/icicle.go
index 92c4834..768783b 100644
--- a/internal/tui/dashboard/icicle.go
+++ b/internal/tui/dashboard/icicle.go
@@ -1,10 +1,11 @@
package dashboard
import (
+ "cmp"
"fmt"
"math"
"path/filepath"
- "sort"
+ "slices"
"strings"
"ior/internal/statsengine"
@@ -169,13 +170,13 @@ func sortedIcicleChildren(node *icicleNode, metric bubbleMetric) []*icicleNode {
for _, child := range node.children {
out = append(out, child)
}
- sort.Slice(out, func(i, j int) bool {
- vi := icicleValue(out[i], metric)
- vj := icicleValue(out[j], metric)
- if vi != vj {
- return vi > vj
+ slices.SortFunc(out, func(a, b *icicleNode) int {
+ va := icicleValue(a, metric)
+ vb := icicleValue(b, metric)
+ if va != vb {
+ return cmp.Compare(vb, va)
}
- return out[i].name < out[j].name
+ return cmp.Compare(a.name, b.name)
})
return out
}
diff --git a/internal/tui/dashboard/treemap.go b/internal/tui/dashboard/treemap.go
index 7193952..dd62d13 100644
--- a/internal/tui/dashboard/treemap.go
+++ b/internal/tui/dashboard/treemap.go
@@ -1,10 +1,11 @@
package dashboard
import (
+ "cmp"
"fmt"
"image/color"
"math"
- "sort"
+ "slices"
"strings"
"unicode/utf8"
@@ -131,11 +132,11 @@ func buildSyscallTreemapItems(snap *statsengine.Snapshot, metric bubbleMetric) [
if len(items) == 0 {
return nil
}
- sort.Slice(items, func(i, j int) bool {
- if items[i].Value != items[j].Value {
- return items[i].Value > items[j].Value
+ slices.SortFunc(items, func(a, b syscallTreemapItem) int {
+ if a.Value != b.Value {
+ return cmp.Compare(b.Value, a.Value)
}
- return items[i].Name < items[j].Name
+ return cmp.Compare(a.Name, b.Name)
})
if len(items) > maxSyscallTreemapItems {
items = items[:maxSyscallTreemapItems]
@@ -174,11 +175,11 @@ func buildFilesTreemapItems(snap *statsengine.Snapshot, metric bubbleMetric) []s
if len(items) == 0 {
return nil
}
- sort.Slice(items, func(i, j int) bool {
- if items[i].Value != items[j].Value {
- return items[i].Value > items[j].Value
+ slices.SortFunc(items, func(a, b syscallTreemapItem) int {
+ if a.Value != b.Value {
+ return cmp.Compare(b.Value, a.Value)
}
- return items[i].Name < items[j].Name
+ return cmp.Compare(a.Name, b.Name)
})
if len(items) > maxSyscallTreemapItems {
items = items[:maxSyscallTreemapItems]
@@ -217,11 +218,11 @@ func buildProcessesTreemapItems(snap *statsengine.Snapshot, metric bubbleMetric)
if len(items) == 0 {
return nil
}
- sort.Slice(items, func(i, j int) bool {
- if items[i].Value != items[j].Value {
- return items[i].Value > items[j].Value
+ slices.SortFunc(items, func(a, b syscallTreemapItem) int {
+ if a.Value != b.Value {
+ return cmp.Compare(b.Value, a.Value)
}
- return items[i].Name < items[j].Name
+ return cmp.Compare(a.Name, b.Name)
})
if len(items) > maxSyscallTreemapItems {
items = items[:maxSyscallTreemapItems]