diff options
Diffstat (limited to 'tools/perf/util/ui/browser.c')
-rw-r--r-- | tools/perf/util/ui/browser.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/perf/util/ui/browser.c b/tools/perf/util/ui/browser.c index 611219f80680..5911bba63858 100644 --- a/tools/perf/util/ui/browser.c +++ b/tools/perf/util/ui/browser.c @@ -230,6 +230,29 @@ int ui_browser__refresh(struct ui_browser *self) return 0; } +/* + * Here we're updating nr_entries _after_ we started browsing, i.e. we have to + * forget about any reference to any entry in the underlying data structure, + * that is why we do a SEEK_SET. Think about 'perf top' in the hists browser + * after an output_resort and hist decay. + */ +void ui_browser__update_nr_entries(struct ui_browser *browser, u32 nr_entries) +{ + off_t offset = nr_entries - browser->nr_entries; + + browser->nr_entries = nr_entries; + + if (offset < 0) { + if (browser->top_idx < (u64)-offset) + offset = -browser->top_idx; + + browser->index += offset; + browser->top_idx += offset; + } + + browser->seek(browser, browser->top_idx, SEEK_SET); +} + int ui_browser__run(struct ui_browser *self) { struct newtExitStruct es; |