Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf cgroup: Make evlist__find_cgroup() more compact

By taking advantage that __get() routines return the pointer to the
object for which a reference count is being get.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-xnvd07rdxliy04oi062samik@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+3 -6
+3 -6
tools/perf/util/cgroup.c
··· 93 93 static struct cgroup *evlist__find_cgroup(struct perf_evlist *evlist, const char *str) 94 94 { 95 95 struct perf_evsel *counter; 96 - struct cgroup *cgrp = NULL; 97 96 /* 98 97 * check if cgrp is already defined, if so we reuse it 99 98 */ 100 99 evlist__for_each_entry(evlist, counter) { 101 100 if (!counter->cgrp) 102 101 continue; 103 - if (!strcmp(counter->cgrp->name, str)) { 104 - cgrp = cgroup__get(counter->cgrp); 105 - break; 106 - } 102 + if (!strcmp(counter->cgrp->name, str)) 103 + return cgroup__get(counter->cgrp); 107 104 } 108 105 109 - return cgrp; 106 + return NULL; 110 107 } 111 108 112 109 static struct cgroup *cgroup__new(const char *name)