From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760719AbcBYPNR (ORCPT ); Thu, 25 Feb 2016 10:13:17 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33006 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933097AbcBYPNP (ORCPT ); Thu, 25 Feb 2016 10:13:15 -0500 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Namhyung Kim , Ingo Molnar , Taeung Song Subject: [PATCH 3/3] perf script: Remove duplicated code and needless a script_spec__findnew() Date: Fri, 26 Feb 2016 00:13:10 +0900 Message-Id: <1456413190-12378-1-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org script_spec_register() called two functions script_spec__find() and script_spec__findnew(). But script_spec__find() was called two times. So remove script_spec__findnew() and make script_spec_register() only call once script_spec__find(). Cc: Jiri Olsa Signed-off-by: Taeung Song --- tools/perf/builtin-script.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index ec4fbd4..57f9a7e 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1212,23 +1212,6 @@ static struct script_spec *script_spec__find(const char *spec) return NULL; } -static struct script_spec *script_spec__findnew(const char *spec, - struct scripting_ops *ops) -{ - struct script_spec *s = script_spec__find(spec); - - if (s) - return s; - - s = script_spec__new(spec, ops); - if (!s) - return NULL; - - script_spec__add(s); - - return s; -} - int script_spec_register(const char *spec, struct scripting_ops *ops) { struct script_spec *s; @@ -1237,9 +1220,11 @@ int script_spec_register(const char *spec, struct scripting_ops *ops) if (s) return -1; - s = script_spec__findnew(spec, ops); + s = script_spec__new(spec, ops); if (!s) return -1; + else + script_spec__add(s); return 0; } -- 2.5.0