aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ecore_wl2/ecore_wl2_input.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2018-03-07 09:37:25 -0500
committerChris Michael <cp.michael@samsung.com>2018-03-07 09:37:25 -0500
commita1bb9b313f008f65b06319a1bede1f175c29d3da (patch)
treedc253235e7c67072b444c24020f4026c2d63c9c2 /src/lib/ecore_wl2/ecore_wl2_input.c
parenteolian: get rid of old APIs for typedecl retrieval (diff)
downloadefl-a1bb9b313f008f65b06319a1bede1f175c29d3da.tar.gz
ecore-wl2: Reduce calls to strlen
Small patch to reduce calls to strlen when sending key events. This patch is loosely based on Phab https://phab.enlightenment.org/D5567 @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_wl2/ecore_wl2_input.c')
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_input.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c
index 26d205de04..c252593350 100644
--- a/src/lib/ecore_wl2/ecore_wl2_input.c
+++ b/src/lib/ecore_wl2/ecore_wl2_input.c
@@ -625,6 +625,7 @@ _ecore_wl2_input_key_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, xkb_
{
Ecore_Event_Key *ev;
char key[256], keyname[256], compose[256];
+ int name_len, key_len, comp_len;
memset(key, 0, sizeof(key));
memset(keyname, 0, sizeof(keyname));
@@ -636,18 +637,22 @@ _ecore_wl2_input_key_send(Ecore_Wl2_Input *input, Ecore_Wl2_Window *window, xkb_
_ecore_wl2_input_key_translate(sym, input->keyboard.modifiers,
compose, sizeof(compose));
- ev = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
- ((compose[0] != '\0') ? strlen(compose) : 0) + 3);
+ name_len = strlen(keyname);
+ key_len = strlen(key);
+ comp_len = strlen(compose);
+
+ ev = calloc(1, sizeof(Ecore_Event_Key) + key_len + name_len +
+ ((compose[0] != '\0') ? comp_len : 0) + 3);
if (!ev) return;
ev->keyname = (char *)(ev + 1);
- ev->key = ev->keyname + strlen(keyname) + 1;
- ev->compose = strlen(compose) ? ev->key + strlen(key) + 1 : NULL;
+ ev->key = ev->keyname + name_len + 1;
+ ev->compose = comp_len ? ev->key + key_len + 1 : NULL;
ev->string = ev->compose;
strcpy((char *)ev->keyname, keyname);
strcpy((char *)ev->key, key);
- if (strlen(compose)) strcpy((char *)ev->compose, compose);
+ if (comp_len) strcpy((char *)ev->compose, compose);
ev->window = window->id;
ev->event_window = window->id;