[Vimprobable-users] [PATCH] Use if-else-if in process_set_line().
Vimprobable is a lean web browser optimised for full keyboard control
Brought to you by:
hanness
From: Daniel C. <dan...@gm...> - 2011-11-04 00:45:11
|
There where a long sequence of if statements that could be connected by 'else' to not test strlen and compare my_pair.what it already matched. It's not big issue, but a very little performance increasement. Daniel --- main.c | 30 +++++++++++------------------- 1 files changed, 11 insertions(+), 19 deletions(-) diff --git a/main.c b/main.c index eb1d66f..fbca2d9 100644 --- a/main.c +++ b/main.c @@ -1887,29 +1887,21 @@ process_set_line(char *line) { webkit_web_view_set_settings(webview, settings); } - /* process acceptlanguage*/ - if (strlen(my_pair.what) == 14 && strncmp("acceptlanguage", my_pair.what, 14) == 0) { - g_object_set(G_OBJECT(session), "accept-language", acceptlanguage, NULL); - } - - /* toggle proxy usage? */ - if (strlen(my_pair.what) == 5 && strncmp("proxy", my_pair.what, 5) == 0) { + if (strlen(my_pair.what) == 14) { + if (strncmp("acceptlanguage", my_pair.what, 14) == 0) { + g_object_set(G_OBJECT(session), "accept-language", acceptlanguage, NULL); + } else if (strncmp("completioncase", my_pair.what, 14) == 0) { + complete_case_sensitive = boolval; + } + } else if (strlen(my_pair.what) == 5 && strncmp("proxy", my_pair.what, 5) == 0) { toggle_proxy(boolval); - } - - /* Toggle scrollbars. */ - if (strlen(my_pair.what) == 10 && strncmp("scrollbars", my_pair.what, 10) == 0) + } else if (strlen(my_pair.what) == 10 && strncmp("scrollbars", my_pair.what, 10) == 0) { toggle_scrollbars(boolval); - - /* Toggle widgets */ - if (strlen(my_pair.what) == 9 && strncmp("statusbar", my_pair.what, 9) == 0) + } else if (strlen(my_pair.what) == 9 && strncmp("statusbar", my_pair.what, 9) == 0) { gtk_widget_set_visible(GTK_WIDGET(statusbar), boolval); - if (strlen(my_pair.what) == 8 && strncmp("inputbox", my_pair.what, 8) == 0) + } else if (strlen(my_pair.what) == 8 && strncmp("inputbox", my_pair.what, 8) == 0) { gtk_widget_set_visible(inputbox, boolval); - - /* case sensitivity of completion */ - if (strlen(my_pair.what) == 14 && strncmp("completioncase", my_pair.what, 14) == 0) - complete_case_sensitive = boolval; + } /* reload page? */ if (browsersettings[i].reload) -- 1.7.4.1 |