aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
authorTaeung Song <treeze.taeung@gmail.com>2016-02-25 10:13:10 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-02-25 14:14:33 -0500
commit8560bae02a948876b26d1d86423cf5e0bb04a815 (patch)
treed32a8c3cbd5c8c8a4e1bf3b46adbfd8e681ee8c3 /tools/perf/builtin-script.c
parent8579aca3f9a8f890d6d94ccaed7cf5fd54a0c3bd (diff)
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 <treeze.taeung@gmail.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1456413190-12378-1-git-send-email-treeze.taeung@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index ec4fbd410a4b..57f9a7e7f7d3 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)
1212 return NULL; 1212 return NULL;
1213} 1213}
1214 1214
1215static struct script_spec *script_spec__findnew(const char *spec,
1216 struct scripting_ops *ops)
1217{
1218 struct script_spec *s = script_spec__find(spec);
1219
1220 if (s)
1221 return s;
1222
1223 s = script_spec__new(spec, ops);
1224 if (!s)
1225 return NULL;
1226
1227 script_spec__add(s);
1228
1229 return s;
1230}
1231
1232int script_spec_register(const char *spec, struct scripting_ops *ops) 1215int script_spec_register(const char *spec, struct scripting_ops *ops)
1233{ 1216{
1234 struct script_spec *s; 1217 struct script_spec *s;
@@ -1237,9 +1220,11 @@ int script_spec_register(const char *spec, struct scripting_ops *ops)
1237 if (s) 1220 if (s)
1238 return -1; 1221 return -1;
1239 1222
1240 s = script_spec__findnew(spec, ops); 1223 s = script_spec__new(spec, ops);
1241 if (!s) 1224 if (!s)
1242 return -1; 1225 return -1;
1226 else
1227 script_spec__add(s);
1243 1228
1244 return 0; 1229 return 0;
1245} 1230}