From 9784b3f903e4fafe8440d7cc1c5bc1029f6297ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Wed, 21 Dec 2011 21:40:52 +0100 Subject: [PATCH] command.c: change find_key_command for MAX_COMMAND_KEYS != 3 The performance penalty shouldn't be too high (loop unrolling could help here). --- src/command.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/command.c b/src/command.c index af6afd1..76e84dc 100644 --- a/src/command.c +++ b/src/command.c @@ -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; -- 2.30.2