summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2012-06-18 21:36:42 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2012-06-18 21:36:42 +0000
commita68eeeca8f26ef5d982822aac0dc2bf2cf714c51 (patch)
treec0f3f78bf0518b78882bcd5423d7ae2bdfafc952 /src/bin
parent40a519c8d9e227415a4bc439c4ee5834d7e5475c (diff)
minor speedup to lookup keynames.
just compare the string if input size matches. SVN revision: 72420
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/keyin.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bin/keyin.c b/src/bin/keyin.c
index aab5a74..dda8c51 100644
--- a/src/bin/keyin.c
+++ b/src/bin/keyin.c
@@ -8,10 +8,11 @@ struct _Keyout
8{ 8{
9 const char *in; 9 const char *in;
10 const char *out; 10 const char *out;
11 int inlen;
11 int outlen; 12 int outlen;
12}; 13};
13 14
14#define KEY(in, out) {in, out, sizeof(out) - 1} 15#define KEY(in, out) {in, out, sizeof(in) - 1, sizeof(out) - 1}
15 16
16static const Keyout crlf_keyout[] = 17static const Keyout crlf_keyout[] =
17{ 18{
@@ -175,12 +176,14 @@ static const Keyout kps_keyout[] =
175static Eina_Bool 176static Eina_Bool
176_key_try(Termpty *ty, const Keyout *map, Evas_Event_Key_Down *ev) 177_key_try(Termpty *ty, const Keyout *map, Evas_Event_Key_Down *ev)
177{ 178{
178 int i; 179 int i, inlen;
179 180
180 if (!ev->keyname) return EINA_FALSE; 181 if (!ev->keyname) return EINA_FALSE;
182
183 inlen = strlen(ev->keyname);
181 for (i = 0; map[i].in; i++) 184 for (i = 0; map[i].in; i++)
182 { 185 {
183 if (!strcmp(ev->keyname, map[i].in)) 186 if ((inlen == map[i].inlen) && (!memcmp(ev->keyname, map[i].in, inlen)))
184 { 187 {
185 termpty_write(ty, map[i].out, map[i].outlen); 188 termpty_write(ty, map[i].out, map[i].outlen);
186 return EINA_TRUE; 189 return EINA_TRUE;