perf sort: Consolidate sort_entry__setup_elide()
authorNamhyung Kim <namhyung.kim@lge.com>
Wed, 3 Apr 2013 12:26:19 +0000 (21:26 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 28 May 2013 13:23:54 +0000 (16:23 +0300)
The same code was duplicate to places, factor them out to common
sort__setup_elide().

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1364991979-3008-11-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-diff.c
tools/perf/builtin-report.c
tools/perf/builtin-top.c
tools/perf/util/sort.c
tools/perf/util/sort.h

index 2d0462d89a972ffde8d1ef24e1c9262c45cb3ac7..cabbea5f0bc22de57923646d52ae5928895bde55 100644 (file)
@@ -611,9 +611,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused)
 
        setup_pager();
 
-       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", NULL);
-       sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", NULL);
-       sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", NULL);
+       sort__setup_elide(NULL);
 
        return __cmd_diff();
 }
index 669405c9b8a28df614279308c402ce020cd56cb5..d45bf9b0361da7f73cb1e1b87293c91daefbbe2c 100644 (file)
@@ -937,25 +937,7 @@ repeat:
                report.symbol_filter_str = argv[0];
        }
 
-       sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout);
-
-       if (sort__mode == SORT_MODE__BRANCH) {
-               sort_entry__setup_elide(&sort_dso_from, symbol_conf.dso_from_list, "dso_from", stdout);
-               sort_entry__setup_elide(&sort_dso_to, symbol_conf.dso_to_list, "dso_to", stdout);
-               sort_entry__setup_elide(&sort_sym_from, symbol_conf.sym_from_list, "sym_from", stdout);
-               sort_entry__setup_elide(&sort_sym_to, symbol_conf.sym_to_list, "sym_to", stdout);
-       } else {
-               if (report.mem_mode) {
-                       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "symbol_daddr", stdout);
-                       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso_daddr", stdout);
-                       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "mem", stdout);
-                       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "local_weight", stdout);
-                       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "tlb", stdout);
-                       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "snoop", stdout);
-               }
-               sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout);
-               sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout);
-       }
+       sort__setup_elide(stdout);
 
        ret = __cmd_report(&report);
        if (ret == K_SWITCH_INPUT_DATA) {
index 67bdb9f14ad61ea765476113ffb61d0f50a57e05..2eb272d8753cb9d8f3604e3cb0d097cb3d24b4a7 100644 (file)
@@ -1200,9 +1200,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
        if (symbol__init() < 0)
                return -1;
 
-       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list, "dso", stdout);
-       sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list, "comm", stdout);
-       sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list, "symbol", stdout);
+       sort__setup_elide(stdout);
 
        /*
         * Avoid annotation data structures overhead when symbols aren't on the
index 1dbf169492506be32ac4175c414d25891b90a0c1..701ab1d848940f8c182f88aa1a198980b0443c37 100644 (file)
@@ -1,5 +1,6 @@
 #include "sort.h"
 #include "hist.h"
+#include "symbol.h"
 
 regex_t                parent_regex;
 const char     default_parent_pattern[] = "^sys_|^do_page_fault";
@@ -1009,8 +1010,9 @@ int setup_sorting(void)
        return ret;
 }
 
-void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
-                            const char *list_name, FILE *fp)
+static void sort_entry__setup_elide(struct sort_entry *self,
+                                   struct strlist *list,
+                                   const char *list_name, FILE *fp)
 {
        if (list && strlist__nr_entries(list) == 1) {
                if (fp != NULL)
@@ -1019,3 +1021,42 @@ void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
                self->elide = true;
        }
 }
+
+void sort__setup_elide(FILE *output)
+{
+       sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
+                               "dso", output);
+       sort_entry__setup_elide(&sort_comm, symbol_conf.comm_list,
+                               "comm", output);
+       sort_entry__setup_elide(&sort_sym, symbol_conf.sym_list,
+                               "symbol", output);
+
+       if (sort__mode == SORT_MODE__BRANCH) {
+               sort_entry__setup_elide(&sort_dso_from,
+                                       symbol_conf.dso_from_list,
+                                       "dso_from", output);
+               sort_entry__setup_elide(&sort_dso_to,
+                                       symbol_conf.dso_to_list,
+                                       "dso_to", output);
+               sort_entry__setup_elide(&sort_sym_from,
+                                       symbol_conf.sym_from_list,
+                                       "sym_from", output);
+               sort_entry__setup_elide(&sort_sym_to,
+                                       symbol_conf.sym_to_list,
+                                       "sym_to", output);
+       } else if (sort__mode == SORT_MODE__MEMORY) {
+               sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
+                                       "symbol_daddr", output);
+               sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
+                                       "dso_daddr", output);
+               sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
+                                       "mem", output);
+               sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
+                                       "local_weight", output);
+               sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
+                                       "tlb", output);
+               sort_entry__setup_elide(&sort_dso, symbol_conf.dso_list,
+                                       "snoop", output);
+       }
+
+}
index 0232d476da87f5913f7a1e624eb4f03a5aa9d084..51f1b5a854e781924d4d3f23bd308a8a34d86189 100644 (file)
@@ -181,7 +181,6 @@ extern struct list_head hist_entry__sort_list;
 
 int setup_sorting(void);
 extern int sort_dimension__add(const char *);
-void sort_entry__setup_elide(struct sort_entry *self, struct strlist *list,
-                            const char *list_name, FILE *fp);
+void sort__setup_elide(FILE *fp);
 
 #endif /* __PERF_SORT_H */