Commit b72ccbc5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

ConfigKeyToString: binary search

parent 90ee09e8
...@@ -175,8 +175,7 @@ char *KeyToString (uint_fast32_t sym) ...@@ -175,8 +175,7 @@ char *KeyToString (uint_fast32_t sym)
{ {
key_descriptor_t *d; key_descriptor_t *d;
d = (key_descriptor_t *) d = bsearch ((void *)(uintptr_t)sym, vlc_keys, vlc_num_keys,
bsearch ((void *)(uintptr_t)sym, vlc_keys, vlc_num_keys,
sizeof (vlc_keys[0]), cmpkey); sizeof (vlc_keys[0]), cmpkey);
return d ? strdup (d->psz_key_string) : NULL; return d ? strdup (d->psz_key_string) : NULL;
} }
...@@ -238,14 +237,16 @@ char *ConfigKeyToString (uint_fast32_t i_key) ...@@ -238,14 +237,16 @@ char *ConfigKeyToString (uint_fast32_t i_key)
vlc_modifiers[i].psz_key_string); vlc_modifiers[i].psz_key_string);
} }
} }
for (size_t i = 0; i < vlc_num_keys; i++)
{ key_descriptor_t *d;
if ((i_key & ~KEY_MODIFIER) == vlc_keys[i].i_key_code)
{ i_key &= ~KEY_MODIFIER;
p += snprintf (p, psz_end - p, "%s", d = bsearch ((void *)(uintptr_t)i_key, vlc_keys, vlc_num_keys,
vlc_keys[i].psz_key_string); sizeof (vlc_keys[0]), cmpkey);
break; if (d)
} p += snprintf (p, psz_end - p, "%s", d->psz_key_string);
} else
return NULL;
return psz_key; return psz_key;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment