From: Jonathan Neuschäfer Date: Wed, 21 Dec 2011 20:40:52 +0000 (+0100) Subject: command.c: change find_key_command for MAX_COMMAND_KEYS != 3 X-Git-Tag: release-0.20~38 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9784b3f903e4fafe8440d7cc1c5bc1029f6297ce;p=ncmpc.git command.c: change find_key_command for MAX_COMMAND_KEYS != 3 The performance penalty shouldn't be too high (loop unrolling could help here). --- 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;