[MPlayer-cvslog] r37836 - in trunk/input: input.c input.h
reimar
subversion at mplayerhq.hu
Sun Mar 6 14:00:52 CET 2016
Author: reimar
Date: Sun Mar 6 14:00:52 2016
New Revision: 37836
Log:
input: optimize key_names list.
Avoid relocations for string pointers.
Modified:
trunk/input/input.c
trunk/input/input.h
Modified: trunk/input/input.c
==============================================================================
--- trunk/input/input.c Sun Mar 6 14:00:51 2016 (r37835)
+++ trunk/input/input.c Sun Mar 6 14:00:52 2016 (r37836)
@@ -372,7 +372,7 @@ static const mp_key_name_t key_names[] =
{ KEY_CLOSE_WIN, "CLOSE_WIN" },
- { 0, NULL }
+ { 0, "" }
};
// This is the default binding. The content of input.conf overrides these.
@@ -1465,7 +1465,7 @@ static char*
mp_input_get_key_name(int key) {
int i;
- for(i = 0; key_names[i].name != NULL; i++) {
+ for(i = 0; key_names[i].name[0]; i++) {
if(key_names[i].key == key)
return key_names[i].name;
}
@@ -1491,7 +1491,7 @@ mp_input_get_key_from_name(const char *n
} else if(len > 2 && strncasecmp("0x",name,2) == 0)
return strtol(name,NULL,16);
- for(i = 0; key_names[i].name != NULL; i++) {
+ for(i = 0; key_names[i].name[0]; i++) {
if(strcasecmp(key_names[i].name,name) == 0)
return key_names[i].key;
}
@@ -1859,7 +1859,7 @@ mp_input_register_options(m_config_t* cf
static int mp_input_print_key_list(m_option_t* cfg) {
int i;
printf("\n");
- for(i= 0; key_names[i].name != NULL ; i++)
+ for(i= 0; key_names[i].name[0] ; i++)
printf("%s\n",key_names[i].name);
exit(0);
}
Modified: trunk/input/input.h
==============================================================================
--- trunk/input/input.h Sun Mar 6 14:00:51 2016 (r37835)
+++ trunk/input/input.h Sun Mar 6 14:00:52 2016 (r37836)
@@ -243,7 +243,7 @@ typedef struct mp_cmd_bind {
typedef struct mp_key_name {
int key;
- char* name;
+ char name[20];
} mp_key_name_t;
// These typedefs are for the drivers. They are the functions used to retrieve
More information about the MPlayer-cvslog
mailing list