public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] perf script: Remove duplicated code and needless a script_spec__findnew()
@ 2016-02-25 15:13 Taeung Song
  2016-02-25 19:02 ` Jiri Olsa
  2016-02-27  9:41 ` [tip:perf/core] perf script: Remove duplicated code and needless script_spec__findnew() tip-bot for Taeung Song
  0 siblings, 2 replies; 6+ messages in thread
From: Taeung Song @ 2016-02-25 15:13 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Jiri Olsa, Namhyung Kim, Ingo Molnar, Taeung Song

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 <jolsa@kernel.org>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-02-27  9:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-25 15:13 [PATCH 3/3] perf script: Remove duplicated code and needless a script_spec__findnew() Taeung Song
2016-02-25 19:02 ` Jiri Olsa
2016-02-25 19:06   ` Taeung Song
2016-02-25 19:16   ` Arnaldo Carvalho de Melo
2016-02-25 19:17     ` Taeung Song
2016-02-27  9:41 ` [tip:perf/core] perf script: Remove duplicated code and needless script_spec__findnew() tip-bot for Taeung Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox