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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f622df5e
...@@ -93,20 +93,17 @@ static int open_cgroup(const char *name) ...@@ -93,20 +93,17 @@ static int open_cgroup(const char *name)
static struct cgroup *evlist__find_cgroup(struct perf_evlist *evlist, const char *str) static struct cgroup *evlist__find_cgroup(struct perf_evlist *evlist, const char *str)
{ {
struct perf_evsel *counter; struct perf_evsel *counter;
struct cgroup *cgrp = NULL;
/* /*
* check if cgrp is already defined, if so we reuse it * check if cgrp is already defined, if so we reuse it
*/ */
evlist__for_each_entry(evlist, counter) { evlist__for_each_entry(evlist, counter) {
if (!counter->cgrp) if (!counter->cgrp)
continue; continue;
if (!strcmp(counter->cgrp->name, str)) { if (!strcmp(counter->cgrp->name, str))
cgrp = cgroup__get(counter->cgrp); return cgroup__get(counter->cgrp);
break;
}
} }
return cgrp; return NULL;
} }
static struct cgroup *cgroup__new(const char *name) static struct cgroup *cgroup__new(const char *name)
......
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