From 9322e1e6a4ff8c0ceb58fb325e06b59d3d7dad11 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@justemail.net> Date: Mon, 25 Jul 2016 10:30:41 +0200 Subject: [PATCH] tweaks: reshuffle two ifs for a little more speed Saving roughly twenty microseconds at startup. --- src/global.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/global.c b/src/global.c index 1ece3219..7f72810d 100644 --- a/src/global.c +++ b/src/global.c @@ -406,18 +406,17 @@ void assign_keyinfo(sc *s, const char *keystring) assert(strlen(keystring) > 1 && (!s->meta || strlen(keystring) > 2)); - if (keystring[0] == '^') + if (keystring[0] == '^') { s->keycode = s->keystr[1] - 64; - else if (s->meta) + if (strcasecmp(keystring, "^Space") == 0) + s->keycode = 0; + } else if (s->meta) { s->keycode = tolower((int) s->keystr[2]); - else if (keystring[0] == 'F') + if (strcasecmp(keystring, "M-Space") == 0) + s->keycode = (int)' '; + } else if (keystring[0] == 'F') s->keycode = KEY_F0 + atoi(&s->keystr[1]); - /* Catch the strings that don't bind as easily as we'd like. */ - if (strcasecmp(s->keystr, "^Space") == 0) - s->keycode = 0; - else if (strcasecmp(s->keystr, "M-Space") == 0) - s->keycode = (int) ' '; else if (!strcasecmp(s->keystr, "Up")) s->keycode = KEY_UP; else if (!strcasecmp(s->keystr, "Down")) -- GitLab