summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/tui/flamegraph/controls.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/internal/tui/flamegraph/controls.go b/internal/tui/flamegraph/controls.go
index 8333abb..7fef839 100644
--- a/internal/tui/flamegraph/controls.go
+++ b/internal/tui/flamegraph/controls.go
@@ -39,15 +39,23 @@ func (m *Model) clearSnapshotState(clearSearch bool) {
m.globalTotal = 0
m.frames = nil
m.targetFrames = nil
- m.matchIndices = make(map[int]bool)
- m.filterVisible = make(map[int]bool)
- m.subtreeSet = make(map[int]bool)
+ m.matchIndices = resetBoolSet(m.matchIndices)
+ m.filterVisible = resetBoolSet(m.filterVisible)
+ m.subtreeSet = resetBoolSet(m.subtreeSet)
m.hasNavigableSnapshot = false
if clearSearch {
m.searchQuery = ""
}
}
+func resetBoolSet(values map[int]bool) map[int]bool {
+ if values == nil {
+ return make(map[int]bool)
+ }
+ clear(values)
+ return values
+}
+
func (m *Model) resetBaseline() {
if m.liveTrie != nil {
m.liveTrie.Reset()