diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-13 14:41:18 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-13 14:41:18 +0300 |
| commit | d392eebe5bd127e1573734321b0cabaad4182d7c (patch) | |
| tree | e6e0b38ba26110411d80e00b224640c26b8110ae /internal/tui/flamegraph/model.go | |
| parent | de6b9c4741dea87ce66e0309bac580030490dc30 (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/flamegraph/model.go')
| -rw-r--r-- | internal/tui/flamegraph/model.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/tui/flamegraph/model.go b/internal/tui/flamegraph/model.go index c188323..3c63c3e 100644 --- a/internal/tui/flamegraph/model.go +++ b/internal/tui/flamegraph/model.go @@ -506,11 +506,17 @@ func (m Model) renderViewContent() string { if m.snapshot != nil && len(m.frames) == 0 { content = common.PanelStyle.Render(fmt.Sprintf("Flame: snapshot v%d has no visible frames", m.lastVersion)) } - content += "\n" + m.selectionStatusLine() + // Assemble the final output using a Builder to avoid repeated string copies + // for the optional help-overlay suffix. + var b strings.Builder + b.WriteString(content) + b.WriteString("\n") + b.WriteString(m.selectionStatusLine()) if m.showHelp { - content += "\n" + m.helpOverlay() + b.WriteString("\n") + b.WriteString(m.helpOverlay()) } - return content + return b.String() } // currentViewCacheKey snapshots every Model field that influences View() |
