From 0a8fd379dbd0c222beffa785bdfb5b1f2509f368 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Thu, 24 Nov 2016 00:21:54 -0200 Subject: [PATCH] efl_loop_fd: reduce number of _efl_loop_fd_reset() When we're adding callbacks in an array, we may reduce 3 epoll_ctl() to a single one. --- src/lib/ecore/efl_loop_fd.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/lib/ecore/efl_loop_fd.c b/src/lib/ecore/efl_loop_fd.c index 594eea4cd4..7d3cd6aca8 100644 --- a/src/lib/ecore/efl_loop_fd.c +++ b/src/lib/ecore/efl_loop_fd.c @@ -97,6 +97,7 @@ _check_fd_event_catcher_add(void *data, const Efl_Event *event) { const Efl_Callback_Array_Item *array = event->info; Efl_Loop_Fd_Data *fd = data; + Eina_Bool need_reset = EINA_FALSE; int i; for (i = 0; array[i].desc != NULL; i++) @@ -104,19 +105,22 @@ _check_fd_event_catcher_add(void *data, const Efl_Event *event) if (array[i].desc == EFL_LOOP_FD_EVENT_READ) { if (fd->references.read++ > 0) continue; - _efl_loop_fd_reset(event->object, fd); + need_reset = EINA_TRUE; } else if (array[i].desc == EFL_LOOP_FD_EVENT_WRITE) { if (fd->references.write++ > 0) continue; - _efl_loop_fd_reset(event->object, fd); + need_reset = EINA_TRUE; } if (array[i].desc == EFL_LOOP_FD_EVENT_ERROR) { if (fd->references.error++ > 0) continue; - _efl_loop_fd_reset(event->object, fd); + need_reset = EINA_TRUE; } } + + if (need_reset) + _efl_loop_fd_reset(event->object, fd); } static void @@ -124,6 +128,7 @@ _check_fd_event_catcher_del(void *data, const Efl_Event *event) { const Efl_Callback_Array_Item *array = event->info; Efl_Loop_Fd_Data *fd = data; + Eina_Bool need_reset = EINA_FALSE; int i; for (i = 0; array[i].desc != NULL; i++) @@ -131,19 +136,22 @@ _check_fd_event_catcher_del(void *data, const Efl_Event *event) if (array[i].desc == EFL_LOOP_FD_EVENT_READ) { if (fd->references.read-- > 1) continue; - _efl_loop_fd_reset(event->object, fd); + need_reset = EINA_TRUE; } else if (array[i].desc == EFL_LOOP_FD_EVENT_WRITE) { if (fd->references.write-- > 1) continue; - _efl_loop_fd_reset(event->object, fd); + need_reset = EINA_TRUE; } if (array[i].desc == EFL_LOOP_FD_EVENT_ERROR) { if (fd->references.error-- > 1) continue; - _efl_loop_fd_reset(event->object, fd); + need_reset = EINA_TRUE; } } + + if (need_reset) + _efl_loop_fd_reset(event->object, fd); } EFL_CALLBACKS_ARRAY_DEFINE(fd_watch,