Code

command.c: change find_key_command for MAX_COMMAND_KEYS != 3
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 21 Dec 2011 20:40:52 +0000 (21:40 +0100)
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 21 Dec 2011 20:59:29 +0000 (21:59 +0100)
The performance penalty shouldn't be too high (loop unrolling could
help here).

src/command.c

index af6afd15a01ee7e93ab01a31e72cfa6a4f301e2d..76e84dc1c897c244335454d1dc7cf4078e9e9c81 100644 (file)
@@ -407,10 +407,9 @@ find_key_command(int key, command_definition_t *c)
        assert(c != NULL);
 
        for (int i = 0; c[i].name; i++) {
-               if (c[i].keys[0] == key ||
-                   c[i].keys[1] == key ||
-                   c[i].keys[2] == key)
-                       return c[i].command;
+               for (int j = 0; j < MAX_COMMAND_KEYS; j++)
+                       if (c[i].keys[j] == key)
+                               return c[i].command;
        }
 
        return CMD_NONE;