diff options
| author | Namhyung Kim <namhyung.kim@lge.com> | 2013-04-03 08:26:10 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-05-28 09:23:53 -0400 |
| commit | 2f532d09fa3a7eaf7cf1c23de9767eab8c8c0e7e (patch) | |
| tree | c4731ac35cd5ecf6bc7201bce7e4069c0321dd38 /tools/perf/util | |
| parent | 55369fc179b0572d0b4a06a9be1d2779b3ac22e0 (diff) | |
perf sort: Factor out common code in sort_dimension__add()
Let's remove duplicate code.
Suggested-by: Jiri Olsa <jolsa@redhat.com>
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-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
| -rw-r--r-- | tools/perf/util/sort.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index a6ddad41d57a..a997955085eb 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
| @@ -895,6 +895,21 @@ static struct sort_dimension bstack_sort_dimensions[] = { | |||
| 895 | 895 | ||
| 896 | #undef DIM | 896 | #undef DIM |
| 897 | 897 | ||
| 898 | static void __sort_dimension__add(struct sort_dimension *sd, enum sort_type idx) | ||
| 899 | { | ||
| 900 | if (sd->taken) | ||
| 901 | return; | ||
| 902 | |||
| 903 | if (sd->entry->se_collapse) | ||
| 904 | sort__need_collapse = 1; | ||
| 905 | |||
| 906 | if (list_empty(&hist_entry__sort_list)) | ||
| 907 | sort__first_dimension = idx; | ||
| 908 | |||
| 909 | list_add_tail(&sd->entry->list, &hist_entry__sort_list); | ||
| 910 | sd->taken = 1; | ||
| 911 | } | ||
| 912 | |||
| 898 | int sort_dimension__add(const char *tok) | 913 | int sort_dimension__add(const char *tok) |
| 899 | { | 914 | { |
| 900 | unsigned int i; | 915 | unsigned int i; |
| @@ -922,18 +937,7 @@ int sort_dimension__add(const char *tok) | |||
| 922 | sort__has_sym = 1; | 937 | sort__has_sym = 1; |
| 923 | } | 938 | } |
| 924 | 939 | ||
| 925 | if (sd->taken) | 940 | __sort_dimension__add(sd, i); |
| 926 | return 0; | ||
| 927 | |||
| 928 | if (sd->entry->se_collapse) | ||
| 929 | sort__need_collapse = 1; | ||
| 930 | |||
| 931 | if (list_empty(&hist_entry__sort_list)) | ||
| 932 | sort__first_dimension = i; | ||
| 933 | |||
| 934 | list_add_tail(&sd->entry->list, &hist_entry__sort_list); | ||
| 935 | sd->taken = 1; | ||
| 936 | |||
| 937 | return 0; | 941 | return 0; |
| 938 | } | 942 | } |
| 939 | 943 | ||
| @@ -949,18 +953,7 @@ int sort_dimension__add(const char *tok) | |||
| 949 | if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to) | 953 | if (sd->entry == &sort_sym_from || sd->entry == &sort_sym_to) |
| 950 | sort__has_sym = 1; | 954 | sort__has_sym = 1; |
| 951 | 955 | ||
| 952 | if (sd->taken) | 956 | __sort_dimension__add(sd, i + __SORT_BRANCH_STACK); |
| 953 | return 0; | ||
| 954 | |||
| 955 | if (sd->entry->se_collapse) | ||
| 956 | sort__need_collapse = 1; | ||
| 957 | |||
| 958 | if (list_empty(&hist_entry__sort_list)) | ||
| 959 | sort__first_dimension = i + __SORT_BRANCH_STACK; | ||
| 960 | |||
| 961 | list_add_tail(&sd->entry->list, &hist_entry__sort_list); | ||
| 962 | sd->taken = 1; | ||
| 963 | |||
| 964 | return 0; | 957 | return 0; |
| 965 | } | 958 | } |
| 966 | 959 | ||
