summaryrefslogtreecommitdiff
path: root/internal/tui/dashboard/treemap.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-13 14:41:18 +0300
committerPaul Buetow <paul@buetow.org>2026-05-13 14:41:18 +0300
commitd392eebe5bd127e1573734321b0cabaad4182d7c (patch)
treee6e0b38ba26110411d80e00b224640c26b8110ae /internal/tui/dashboard/treemap.go
parentde6b9c4741dea87ce66e0309bac580030490dc30 (diff)
perf: replace string += concatenation with strings.Builder in TUI render hot paths
Swap out ad-hoc += string concatenation in the flamegraph toolbar/status lines, dashboard filter summary, bubble/treemap status lines, eventstream view, processes tab, and probes list for strings.Builder, eliminating redundant allocations on every render tick. Also update dashboard/model_test.go fake SnapshotSource implementations to match the updated interface signature. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tui/dashboard/treemap.go')
-rw-r--r--internal/tui/dashboard/treemap.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/internal/tui/dashboard/treemap.go b/internal/tui/dashboard/treemap.go
index 03c2917..4d5486a 100644
--- a/internal/tui/dashboard/treemap.go
+++ b/internal/tui/dashboard/treemap.go
@@ -438,7 +438,10 @@ func treemapStatusLine(items []syscallTreemapItem, selected int, metric bubbleMe
default:
metricText = fmt.Sprintf("%d", item.Count)
}
- status := fmt.Sprintf(
+ // Use a Builder to avoid a redundant allocation for the optional detail suffix
+ // appended conditionally on every render call.
+ var b strings.Builder
+ b.WriteString(fmt.Sprintf(
"sel:%d/%d %s | %s=%s | bytes=%s",
selected+1,
len(items),
@@ -446,11 +449,12 @@ func treemapStatusLine(items []syscallTreemapItem, selected int, metric bubbleMe
treemapMetricLabel(metric),
metricText,
formatBytes(float64(item.Bytes)),
- )
+ ))
if detail := strings.TrimSpace(item.Detail); detail != "" {
- status += " | " + detail
+ b.WriteString(" | ")
+ b.WriteString(detail)
}
- return status
+ return b.String()
}
func treemapMetricLabel(metric bubbleMetric) string {