From: Kim Phillips Subject: [PATCH 3/3 v2] perf symbols: convert symbol__is_idle to use strlist Date: Mon, 10 Feb 2020 10:31:47 -0600 Message-ID: <20200210163147.25358-1-kim.phillips@amd.com> References: <20200207230613.26709-1-kim.phillips@amd.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20200207230613.26709-1-kim.phillips@amd.com> Sender: linux-kernel-owner@vger.kernel.org To: Arnaldo Carvalho de Melo , kim.phillips@amd.com Cc: Peter Zijlstra , Ingo Molnar , Andi Kleen , Mark Rutland , Alexander Shishkin , Jiri Olsa , Jiri Olsa , Namhyung Kim , Cong Wang , Jin Yao , Kan Liang , Song Liu , Davidlohr Bueso , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: linux-perf-users.vger.kernel.org Use the more optimized strlist implementation to do the idle function lookup. Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Andi Kleen Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Jiri Olsa Cc: Namhyung Kim Cc: Cong Wang Cc: Jin Yao Cc: Kan Liang Cc: Kim Phillips Cc: Song Liu Cc: Davidlohr Bueso Cc: linux-perf-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Kim Phillips --- v2: new this series, based on Jiri's comment: https://lore.kernel.org/lkml/20200120092844.GC608405@krava/ ...and this time with the Cc list intact. tools/perf/util/symbol.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index f3120c4f47ad..1077013d8ce2 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -654,13 +654,17 @@ static bool symbol__is_idle(const char *name) NULL }; int i; + static struct strlist *idle_symbols_list; - for (i = 0; idle_symbols[i]; i++) { - if (!strcmp(idle_symbols[i], name)) - return true; - } + if (idle_symbols_list) + return strlist__has_entry(idle_symbols_list, name); - return false; + idle_symbols_list = strlist__new(NULL, NULL); + + for (i = 0; idle_symbols[i]; i++) + strlist__add(idle_symbols_list, idle_symbols[i]); + + return strlist__has_entry(idle_symbols_list, name); } static int map__process_kallsym_symbol(void *arg, const char *name, -- 2.25.0