From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423484AbcB0JlP (ORCPT ); Sat, 27 Feb 2016 04:41:15 -0500 Received: from torg.zytor.com ([198.137.202.12]:39128 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756333AbcB0JlL (ORCPT ); Sat, 27 Feb 2016 04:41:11 -0500 Date: Sat, 27 Feb 2016 01:41:00 -0800 From: tip-bot for Taeung Song Message-ID: Cc: acme@redhat.com, jolsa@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, treeze.taeung@gmail.com, namhyung@kernel.org Reply-To: acme@redhat.com, jolsa@kernel.org, linux-kernel@vger.kernel.org, mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com, treeze.taeung@gmail.com, namhyung@kernel.org In-Reply-To: <1456413190-12378-1-git-send-email-treeze.taeung@gmail.com> References: <1456413190-12378-1-git-send-email-treeze.taeung@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf script: Remove duplicated code and needless script_spec__findnew() Git-Commit-ID: 8560bae02a948876b26d1d86423cf5e0bb04a815 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 8560bae02a948876b26d1d86423cf5e0bb04a815 Gitweb: http://git.kernel.org/tip/8560bae02a948876b26d1d86423cf5e0bb04a815 Author: Taeung Song AuthorDate: Fri, 26 Feb 2016 00:13:10 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 25 Feb 2016 16:14:33 -0300 perf script: Remove duplicated code and needless script_spec__findnew() script_spec_register() called two functions: script_spec__find() and script_spec__findnew(). But this way script_spec__find() gets called two times, directly and via script_spec__findnew(). So remove script_spec__findnew() and make script_spec_register() only call once script_spec__find(). Signed-off-by: Taeung Song Acked-by: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/r/1456413190-12378-1-git-send-email-treeze.taeung@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- 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; }