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".master
parent
ef7c78910c
commit
2a73b4a050
15
src/global.c
15
src/global.c
|
@ -486,18 +486,21 @@ functionptrtype func_from_key(int *kbinput)
|
||||||
int keycode_from_string(const char *keystring)
|
int keycode_from_string(const char *keystring)
|
||||||
{
|
{
|
||||||
if (keystring[0] == '^') {
|
if (keystring[0] == '^') {
|
||||||
if (strcasecmp(keystring, "^Space") == 0)
|
if (keystring[2] == '\0') {
|
||||||
return 0;
|
if (keystring[1] == '/')
|
||||||
|
return 31;
|
||||||
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
|
||||||
if (strcmp(keystring, "^H") == 0)
|
if (keystring[1] == 'H')
|
||||||
return KEY_BACKSPACE;
|
return KEY_BACKSPACE;
|
||||||
#endif
|
#endif
|
||||||
if (keystring[1] == '/' && keystring[2] == '\0')
|
if (keystring[1] <= '_')
|
||||||
return 31;
|
|
||||||
if (keystring[1] <= '_' && keystring[2] == '\0')
|
|
||||||
return keystring[1] - 64;
|
return keystring[1] - 64;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
|
} else if (strcasecmp(keystring, "^Space") == 0)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
} else if (keystring[0] == 'M') {
|
} else if (keystring[0] == 'M') {
|
||||||
if (keystring[1] == '-' && keystring[3] == '\0')
|
if (keystring[1] == '-' && keystring[3] == '\0')
|
||||||
return tolower((unsigned char)keystring[2]);
|
return tolower((unsigned char)keystring[2]);
|
||||||
|
|
Loading…
Reference in New Issue