nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 2a73b4a050c9ddf9486494ec8bb32da0bd9f4745
parent ef7c78910c069362a15a51c9f917c1697bbf2f67
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu, 12 Dec 2019 18:40:15 +0100

tweaks: reshuffle a fragment of code, for efficiency

First comparing each keystring that starts with "^" against "^Space"
was a waste of time when only one out of fifty such strings actually
is "^Space".

Diffstat:
Msrc/global.c | 21++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/global.c b/src/global.c @@ -486,16 +486,19 @@ functionptrtype func_from_key(int *kbinput) int keycode_from_string(const char *keystring) { if (keystring[0] == '^') { - if (strcasecmp(keystring, "^Space") == 0) - return 0; + if (keystring[2] == '\0') { + if (keystring[1] == '/') + return 31; #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) - if (strcmp(keystring, "^H") == 0) - return KEY_BACKSPACE; -#endif - if (keystring[1] == '/' && keystring[2] == '\0') - return 31; - if (keystring[1] <= '_' && keystring[2] == '\0') - return keystring[1] - 64; + if (keystring[1] == 'H') + return KEY_BACKSPACE; +#endif + if (keystring[1] <= '_') + return keystring[1] - 64; + else + return -1; + } else if (strcasecmp(keystring, "^Space") == 0) + return 0; else return -1; } else if (keystring[0] == 'M') {