Commit e3b60bc9 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf hists: Factor out hists__reset_column_width()

The stdio and tui has same code to reset hpp format column width.
Factor it out as a new function.
Suggested-and-Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160920053025.13989-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5ff3e7a2
...@@ -2067,7 +2067,6 @@ void hist_browser__init(struct hist_browser *browser, ...@@ -2067,7 +2067,6 @@ void hist_browser__init(struct hist_browser *browser,
struct hists *hists) struct hists *hists)
{ {
struct perf_hpp_fmt *fmt; struct perf_hpp_fmt *fmt;
struct perf_hpp_list_node *node;
browser->hists = hists; browser->hists = hists;
browser->b.refresh = hist_browser__refresh; browser->b.refresh = hist_browser__refresh;
...@@ -2076,15 +2075,10 @@ void hist_browser__init(struct hist_browser *browser, ...@@ -2076,15 +2075,10 @@ void hist_browser__init(struct hist_browser *browser,
browser->b.use_navkeypressed = true; browser->b.use_navkeypressed = true;
browser->show_headers = symbol_conf.show_hist_headers; browser->show_headers = symbol_conf.show_hist_headers;
hists__for_each_format(hists, fmt) { hists__for_each_format(hists, fmt)
perf_hpp__reset_width(fmt, hists);
++browser->b.columns; ++browser->b.columns;
}
/* hierarchy entries have their own hpp list */ hists__reset_column_width(hists);
list_for_each_entry(node, &hists->hpp_formats, list) {
perf_hpp_list__for_each_format(&node->hpp, fmt)
perf_hpp__reset_width(fmt, hists);
}
} }
struct hist_browser *hist_browser__new(struct hists *hists) struct hist_browser *hist_browser__new(struct hists *hists)
......
...@@ -699,6 +699,21 @@ void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists) ...@@ -699,6 +699,21 @@ void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists)
} }
} }
void hists__reset_column_width(struct hists *hists)
{
struct perf_hpp_fmt *fmt;
struct perf_hpp_list_node *node;
hists__for_each_format(hists, fmt)
perf_hpp__reset_width(fmt, hists);
/* hierarchy entries have their own hpp list */
list_for_each_entry(node, &hists->hpp_formats, list) {
perf_hpp_list__for_each_format(&node->hpp, fmt)
perf_hpp__reset_width(fmt, hists);
}
}
void perf_hpp__set_user_width(const char *width_list_str) void perf_hpp__set_user_width(const char *width_list_str)
{ {
struct perf_hpp_fmt *fmt; struct perf_hpp_fmt *fmt;
......
...@@ -717,8 +717,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, ...@@ -717,8 +717,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
int max_cols, float min_pcnt, FILE *fp, int max_cols, float min_pcnt, FILE *fp,
bool use_callchain) bool use_callchain)
{ {
struct perf_hpp_fmt *fmt;
struct perf_hpp_list_node *node;
struct rb_node *nd; struct rb_node *nd;
size_t ret = 0; size_t ret = 0;
const char *sep = symbol_conf.field_sep; const char *sep = symbol_conf.field_sep;
...@@ -729,13 +727,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, ...@@ -729,13 +727,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
init_rem_hits(); init_rem_hits();
hists__for_each_format(hists, fmt) hists__reset_column_width(hists);
perf_hpp__reset_width(fmt, hists);
/* hierarchy entries have their own hpp list */
list_for_each_entry(node, &hists->hpp_formats, list) {
perf_hpp_list__for_each_format(&node->hpp, fmt)
perf_hpp__reset_width(fmt, hists);
}
if (symbol_conf.col_width_list_str) if (symbol_conf.col_width_list_str)
perf_hpp__set_user_width(symbol_conf.col_width_list_str); perf_hpp__set_user_width(symbol_conf.col_width_list_str);
......
...@@ -368,6 +368,7 @@ static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format, ...@@ -368,6 +368,7 @@ static inline bool perf_hpp__should_skip(struct perf_hpp_fmt *format,
void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists); void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, struct hists *hists);
void perf_hpp__reset_sort_width(struct perf_hpp_fmt *fmt, struct hists *hists); void perf_hpp__reset_sort_width(struct perf_hpp_fmt *fmt, struct hists *hists);
void perf_hpp__set_user_width(const char *width_list_str); void perf_hpp__set_user_width(const char *width_list_str);
void hists__reset_column_width(struct hists *hists);
typedef u64 (*hpp_field_fn)(struct hist_entry *he); typedef u64 (*hpp_field_fn)(struct hist_entry *he);
typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front); typedef int (*hpp_callback_fn)(struct perf_hpp *hpp, bool front);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment