diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-05 23:30:38 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-05 23:30:38 +0200 |
| commit | 33dbb917be1e30d3de9640bec18d0c619a1a7f67 (patch) | |
| tree | 8a00d9d646f895a6049ce57c200493a3e06235fc /internal/tui/flamegraph/search.go | |
| parent | 642e3eca14b839c9412a092564f6a76d5777455d (diff) | |
Reduce flamegraph hot-path allocations
Diffstat (limited to 'internal/tui/flamegraph/search.go')
| -rw-r--r-- | internal/tui/flamegraph/search.go | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/internal/tui/flamegraph/search.go b/internal/tui/flamegraph/search.go index 8e392d1..f42c36e 100644 --- a/internal/tui/flamegraph/search.go +++ b/internal/tui/flamegraph/search.go @@ -92,21 +92,25 @@ func (m Model) searchFooter() string { } func replaceFooterLine(content, footer string) string { - lines := strings.Split(content, "\n") - if len(lines) == 0 { + if content == "" { return footer } - lines[len(lines)-1] = footer - return strings.Join(lines, "\n") + lastNewline := strings.LastIndexByte(content, '\n') + if lastNewline == -1 { + return footer + } + return content[:lastNewline+1] + footer } func replaceHeaderLine(content, header string) string { - lines := strings.Split(content, "\n") - if len(lines) == 0 { + if content == "" { + return header + } + firstNewline := strings.IndexByte(content, '\n') + if firstNewline == -1 { return header } - lines[0] = header - return strings.Join(lines, "\n") + return header + content[firstNewline:] } func clearBoolMap[K comparable](values map[K]bool) { |
