summaryrefslogtreecommitdiff
path: root/internal/tui/dashboard/bubbles.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/bubbles.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/bubbles.go')
-rw-r--r--internal/tui/dashboard/bubbles.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/internal/tui/dashboard/bubbles.go b/internal/tui/dashboard/bubbles.go
index f4fa6d5..8f9b745 100644
--- a/internal/tui/dashboard/bubbles.go
+++ b/internal/tui/dashboard/bubbles.go
@@ -542,14 +542,19 @@ func (c *bubbleChart) statusLine(width int) string {
}
node := c.nodes[c.selected]
metricText := fmt.Sprintf("%s=%s", c.metricLabel(), c.formatMetricValue(node))
- base := fmt.Sprintf("sel:%d/%d %s | %s | bytes=%s", c.selected+1, len(c.nodes), node.Label, metricText, formatBytes(float64(node.Bytes)))
+ // Use a Builder to avoid extra allocations for the optional hint/detail suffixes
+ // that are appended conditionally on every render.
+ var b strings.Builder
+ b.WriteString(fmt.Sprintf("sel:%d/%d %s | %s | bytes=%s", c.selected+1, len(c.nodes), node.Label, metricText, formatBytes(float64(node.Bytes))))
if c.statusHint != "" {
- base += " | " + c.statusHint
+ b.WriteString(" | ")
+ b.WriteString(c.statusHint)
}
if node.Detail != "" {
- base += " | " + node.Detail
+ b.WriteString(" | ")
+ b.WriteString(node.Detail)
}
- return padOrTrim(base, width)
+ return padOrTrim(b.String(), width)
}
func (c *bubbleChart) metricLabel() string {