From cfb493cf906a86ca7fbdead5cae1d46e2f8f5b68 Mon Sep 17 00:00:00 2001 From: barbieri Date: Mon, 18 Jun 2012 21:36:42 +0000 Subject: [PATCH] minor speedup to lookup keynames. just compare the string if input size matches. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/terminology@72420 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/keyin.c | 9 ++++++--- 1 file 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 { const char *in; const char *out; + int inlen; int outlen; }; -#define KEY(in, out) {in, out, sizeof(out) - 1} +#define KEY(in, out) {in, out, sizeof(in) - 1, sizeof(out) - 1} static const Keyout crlf_keyout[] = { @@ -175,12 +176,14 @@ static const Keyout kps_keyout[] = static Eina_Bool _key_try(Termpty *ty, const Keyout *map, Evas_Event_Key_Down *ev) { - int i; + int i, inlen; if (!ev->keyname) return EINA_FALSE; + + inlen = strlen(ev->keyname); for (i = 0; map[i].in; i++) { - if (!strcmp(ev->keyname, map[i].in)) + if ((inlen == map[i].inlen) && (!memcmp(ev->keyname, map[i].in, inlen))) { termpty_write(ty, map[i].out, map[i].outlen); return EINA_TRUE; -- 2.7.4