diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-03-16 05:14:51 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-03-20 21:36:18 +0300 |
commit | c298304bd747d6a0b733f0becb470ff07ead0317 (patch) | |
tree | 41bd9879719d1305d2d201e64109d6f883c5f2eb /tools/perf/ui/browsers/annotate.c | |
parent | a1e9b74cc2ef80131b9f955c0e1acc25285dc88c (diff) | |
download | linux-c298304bd747d6a0b733f0becb470ff07ead0317.tar.xz |
perf annotate: Use a ops table for annotation_line__write()
To simplify the passing of arguments, the --stdio2 code will have to set
all the fields with operations printing to stdout.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-pcs3c7vdy9ucygxflo4nl1o7@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/browsers/annotate.c')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 2b18c462b882..bed647807d37 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -106,25 +106,29 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); struct annotation *notes = browser__annotation(browser); struct annotation_line *al = list_entry(entry, struct annotation_line, node); - bool current_entry = ui_browser__is_current_entry(browser, row); - bool change_color = (!notes->options->hide_src_code && - (!current_entry || (browser->use_navkeypressed && - !browser->navkeypressed))); - int width = browser->width; + struct annotation_write_ops ops = { + .first_line = row == 0, + .current_entry = ui_browser__is_current_entry(browser, row), + .change_color = (!notes->options->hide_src_code && + (!ops.current_entry || + (browser->use_navkeypressed && + !browser->navkeypressed))), + .width = browser->width, + .obj = browser, + .set_color = annotate_browser__set_color, + .set_percent_color = annotate_browser__set_percent_color, + .set_jumps_percent_color = ui_browser__set_jumps_percent_color, + .printf = annotate_browser__printf, + .write_graph = annotate_browser__write_graph, + }; /* The scroll bar isn't being used */ if (!browser->navkeypressed) - width += 1; + ops.width += 1; - annotation_line__write(al, notes, row == 0, current_entry, change_color, - width, browser, - annotate_browser__set_color, - annotate_browser__set_percent_color, - ui_browser__set_jumps_percent_color, - annotate_browser__printf, - annotate_browser__write_graph); + annotation_line__write(al, notes, &ops); - if (current_entry) + if (ops.current_entry) ab->selection = al; } |