diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-27 08:36:34 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-27 08:36:34 +0300 |
| commit | 116526ad2836778d4d1d27298515448a0a5c53cd (patch) | |
| tree | 96e3e60f7097d5ce6407a6de77d6ce56fcbefad6 /internal | |
| parent | 6f574882eed60fe48fc5bbeeea97f4efb2521427 (diff) | |
flamegraph: reuse clearSnapshotState maps with clear() (ep)
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/tui/flamegraph/controls.go | 14 |
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() |
