summaryrefslogtreecommitdiff
path: root/internal/tui/flamegraph/search.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-05 23:30:38 +0200
committerPaul Buetow <paul@buetow.org>2026-03-05 23:30:38 +0200
commit33dbb917be1e30d3de9640bec18d0c619a1a7f67 (patch)
tree8a00d9d646f895a6049ce57c200493a3e06235fc /internal/tui/flamegraph/search.go
parent642e3eca14b839c9412a092564f6a76d5777455d (diff)
Reduce flamegraph hot-path allocations
Diffstat (limited to 'internal/tui/flamegraph/search.go')
-rw-r--r--internal/tui/flamegraph/search.go20
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) {