diff options
author | Ran Benita <ran234@gmail.com> | 2014-10-18 12:36:40 +0300 |
---|---|---|
committer | Ran Benita <ran234@gmail.com> | 2014-10-18 13:05:18 +0300 |
commit | a4cc119bf500d0c54ef5cc2b7d27a69a64686692 (patch) | |
tree | 8fb600dcd1971aca441eb94c71d62770ff1e4b48 /src/compose | |
parent | a0d2b0297618b4e422deda5e247580747958405d (diff) | |
download | libxkbcommon-a4cc119bf500d0c54ef5cc2b7d27a69a64686692.tar.gz libxkbcommon-a4cc119bf500d0c54ef5cc2b7d27a69a64686692.tar.bz2 libxkbcommon-a4cc119bf500d0c54ef5cc2b7d27a69a64686692.zip |
compose/parser: save len in keysym_from_name cache
This reduces a lot of strcmp's, and allows to use a faster memcmp.
Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/compose')
-rw-r--r-- | src/compose/parser.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/compose/parser.c b/src/compose/parser.c index ebc1ffd..95f0fdd 100644 --- a/src/compose/parser.c +++ b/src/compose/parser.c @@ -75,6 +75,7 @@ OR PERFORMANCE OF THIS SOFTWARE. struct keysym_from_name_cache { struct { char name[64]; + unsigned len; xkb_keysym_t keysym; } cache[KEYSYM_FROM_NAME_CACHE_SIZE]; unsigned next; @@ -90,11 +91,13 @@ cached_keysym_from_name(struct keysym_from_name_cache *cache, return XKB_KEY_NoSymbol; for (unsigned i = 0; i < KEYSYM_FROM_NAME_CACHE_SIZE; i++) - if (streq(cache->cache[i].name, name)) + if (cache->cache[i].len == len && + memcmp(cache->cache[i].name, name, len) == 0) return cache->cache[i].keysym; keysym = xkb_keysym_from_name(name, XKB_KEYSYM_NO_FLAGS); strcpy(cache->cache[cache->next].name, name); + cache->cache[cache->next].len = len; cache->cache[cache->next].keysym = keysym; cache->next = (cache->next + 1) % KEYSYM_FROM_NAME_CACHE_SIZE; return keysym; |