summaryrefslogtreecommitdiff
path: root/internal/tui/flamegraph/search.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-05 23:18:34 +0200
committerPaul Buetow <paul@buetow.org>2026-03-05 23:18:34 +0200
commit8db5b64dcfdd9c75e8b9b8dc42f9b263fa00b64b (patch)
treed0ee37858de76eec0fdc1587764fa9355ed39f91 /internal/tui/flamegraph/search.go
parent4953fd0200eef52f7e1547d5961a2e70e24e49d1 (diff)
Add flamegraph benchmark suite and reuse hot-path buffers
Diffstat (limited to 'internal/tui/flamegraph/search.go')
-rw-r--r--internal/tui/flamegraph/search.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/internal/tui/flamegraph/search.go b/internal/tui/flamegraph/search.go
index f2d6dc0..8e392d1 100644
--- a/internal/tui/flamegraph/search.go
+++ b/internal/tui/flamegraph/search.go
@@ -16,7 +16,7 @@ func (m *Model) openSearch() {
func (m *Model) clearSearch() {
m.searchActive = false
m.searchQuery = ""
- m.matchIndices = make(map[int]bool)
+ clearBoolMap(m.matchIndices)
m.searchInput.SetValue("")
m.searchInput.Blur()
}
@@ -24,7 +24,11 @@ func (m *Model) clearSearch() {
func (m *Model) applySearchQuery(raw string) {
query := strings.ToLower(strings.TrimSpace(raw))
m.searchQuery = query
- m.matchIndices = make(map[int]bool)
+ if m.matchIndices == nil {
+ m.matchIndices = make(map[int]bool)
+ } else {
+ clearBoolMap(m.matchIndices)
+ }
if query == "" {
return
}
@@ -51,7 +55,7 @@ func (m *Model) jumpMatch(direction int) {
} else {
m.selectedIdx = matches[0]
}
- m.subtreeSet = computeSubtreeSet(m.frames, m.selectedIdx)
+ m.subtreeSet = computeSubtreeSetInto(m.frames, m.selectedIdx, m.subtreeSet)
return
}
@@ -63,7 +67,7 @@ func (m *Model) jumpMatch(direction int) {
next = 0
}
m.selectedIdx = matches[next]
- m.subtreeSet = computeSubtreeSet(m.frames, m.selectedIdx)
+ m.subtreeSet = computeSubtreeSetInto(m.frames, m.selectedIdx, m.subtreeSet)
}
func orderedMatchIndices(matchSet map[int]bool) []int {
@@ -104,3 +108,9 @@ func replaceHeaderLine(content, header string) string {
lines[0] = header
return strings.Join(lines, "\n")
}
+
+func clearBoolMap[K comparable](values map[K]bool) {
+ for key := range values {
+ delete(values, key)
+ }
+}