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/eventstream | |
| 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/eventstream')
| -rw-r--r-- | internal/tui/eventstream/model.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/tui/eventstream/model.go b/internal/tui/eventstream/model.go index 2780524..a8f399c 100644 --- a/internal/tui/eventstream/model.go +++ b/internal/tui/eventstream/model.go @@ -500,9 +500,15 @@ func (m *Model) View(width, height int) string { if m.paused && m.selectedIdx >= 0 { status = fmt.Sprintf("Row %d/%d | Sel %d/%d Col %d/%d | Enter push-filter | Esc/F undo", rowNumber(start, len(m.filtered)), len(m.filtered), rowNumber(m.selectedIdx, len(m.filtered)), len(m.filtered), m.selectedCol+1, streamColumnCount) } - out := base + "\n" + status + // Use a Builder to avoid a redundant allocation for the optional status-message + // line appended conditionally on every render call. + var b strings.Builder + b.WriteString(base) + b.WriteString("\n") + b.WriteString(status) if m.statusMessage != "" { - out += "\n" + m.statusMessage + b.WriteString("\n") + b.WriteString(m.statusMessage) } if m.exportModal.Visible() { @@ -511,7 +517,7 @@ func (m *Model) View(width, height int) string { if m.searchModal.Visible() { return m.searchModal.View(width, height) } - return out + return b.String() } func (m *Model) Refresh() { |
