From 116526ad2836778d4d1d27298515448a0a5c53cd Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 27 May 2026 08:36:34 +0300 Subject: flamegraph: reuse clearSnapshotState maps with clear() (ep) --- internal/tui/flamegraph/controls.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'internal') 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() -- cgit v1.2.3