[PATCH 3/5] tools lib traceevent: use else-if cascade, not separate ifs

From: Ramkumar Ramachandra
Date: Mon Mar 17 2014 - 18:27:05 EST


When token cannot be more than one value, it seems wasteful to go
through all the strcmp() calls. Use an else-if cascade instead.

Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx>
---
tools/lib/traceevent/event-parse.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 42bc571..7a8d9ae 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2770,21 +2770,17 @@ process_function(struct event_format *event, struct print_arg *arg,
free_token(token);
is_flag_field = 1;
return process_flags(event, arg, tok);
- }
- if (strcmp(token, "__print_symbolic") == 0) {
+ } else if (strcmp(token, "__print_symbolic") == 0) {
free_token(token);
is_symbolic_field = 1;
return process_symbols(event, arg, tok);
- }
- if (strcmp(token, "__print_hex") == 0) {
+ } else if (strcmp(token, "__print_hex") == 0) {
free_token(token);
return process_hex(event, arg, tok);
- }
- if (strcmp(token, "__get_str") == 0) {
+ } else if (strcmp(token, "__get_str") == 0) {
free_token(token);
return process_str(event, arg, tok);
- }
- if (strcmp(token, "__get_dynamic_array") == 0) {
+ } else if (strcmp(token, "__get_dynamic_array") == 0) {
free_token(token);
return process_dynamic_array(event, arg, tok);
}
--
1.9.0.431.g014438b

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/