]> git.tue.mpg.de Git - paraslash.git/commitdiff
gui: Do not decode the pressed key multiple times.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 28 Apr 2020 19:58:47 +0000 (21:58 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 17 Sep 2020 15:43:02 +0000 (17:43 +0200)
Although the key name is a loop invariant, we recompute it during
every iteration of the loop. Fix this.

gui.c

diff --git a/gui.c b/gui.c
index 0eb5444fc42c60a3fd116f3bdf8fbc76cc698416..d779ff864ddebfc38a34ba1a0d166b5c04089556 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -1049,6 +1049,7 @@ static void handle_command(int c)
 {
        int i;
        const struct lls_opt_result *lor = OPT_RESULT(KEY_MAP);
+       const char *keyname = km_keyname(c);
 
        /* first check user-defined key bindings */
        FOR_EACH_KEY_MAP(i) {
@@ -1059,7 +1060,7 @@ static void handle_command(int c)
                        free(tmp);
                        return;
                }
-               if (strcmp(tmp, km_keyname(c))) {
+               if (strcmp(tmp, keyname)) {
                        free(tmp);
                        continue;
                }
@@ -1079,13 +1080,13 @@ static void handle_command(int c)
        }
        /* not found, check internal key bindings */
        for (i = 0; command_list[i].handler; i++) {
-               if (!strcmp(km_keyname(c), command_list[i].key)) {
+               if (!strcmp(keyname, command_list[i].key)) {
                        command_list[i].handler();
                        return;
                }
        }
        print_in_bar(COLOR_ERRMSG, "key '%s' is not bound, press ? for help",
-               km_keyname(c));
+               keyname);
 }
 
 static int input_post_select(__a_unused struct sched *s,