summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-11-13 16:01:55 -0800
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-11-17 12:12:28 +0100
commit75301b3a1abfebb94249efb6cb01426d763b6099 (patch)
tree06949f5c96a4350143ce88b28c3a0e9aa06f32f3
parent6d20f32cef837d494210e6012cc9ef678b555b7b (diff)
eo: do not over compute the hash when propagating events.
This should slightly improve speed in theory. In practice, I have not seen a benchmark which would budge by 5%, so I am not sure it improve speed that much. Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D10660
-rw-r--r--src/lib/eo/eo_base_class.c62
1 files changed, 38 insertions, 24 deletions
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index f475f5e22e..382beaa8d8 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -1243,10 +1243,11 @@ _pointer_hash(const uintptr_t val)
1243#endif 1243#endif
1244} 1244}
1245 1245
1246#define EFL_OBJECT_EVENT_CB_INC(Obj, It, Pd, Event) \ 1246#define EFL_OBJECT_EVENT_CB_INC(Obj, It, Pd, Event, Update_Hash) \
1247 if (It->desc == Event && !Pd->event_cb_##Event) \ 1247 if (It->desc == Event && !Pd->event_cb_##Event) \
1248 { \ 1248 { \
1249 Pd->event_cb_##Event = EINA_TRUE; \ 1249 Update_Hash = EINA_FALSE; \
1250 Pd->event_cb_##Event = EINA_TRUE; \
1250 } 1251 }
1251 1252
1252#define EFL_OBJECT_EVENT_CB_DEC(Obj, It, Pd, Event) \ 1253#define EFL_OBJECT_EVENT_CB_DEC(Obj, It, Pd, Event) \
@@ -1259,19 +1260,17 @@ _pointer_hash(const uintptr_t val)
1259static inline void 1260static inline void
1260_special_event_count_inc(Eo *obj_id, Efl_Object_Data *pd, const Efl_Callback_Array_Item *it) 1261_special_event_count_inc(Eo *obj_id, Efl_Object_Data *pd, const Efl_Callback_Array_Item *it)
1261{ 1262{
1262 unsigned char event_hash; 1263 Eina_Bool update_hash = EINA_TRUE;
1263
1264 event_hash = _pointer_hash((uintptr_t) it->desc);
1265
1266 pd->callbacks_mask |= 1ULL << event_hash;
1267 1264
1268 EFL_OBJECT_EVENT_CB_INC(obj_id, it, pd, EFL_EVENT_CALLBACK_ADD) 1265 EFL_OBJECT_EVENT_CB_INC(obj_id, it, pd, EFL_EVENT_CALLBACK_ADD, update_hash)
1269 else EFL_OBJECT_EVENT_CB_INC(obj_id, it, pd, EFL_EVENT_CALLBACK_DEL) 1266 else EFL_OBJECT_EVENT_CB_INC(obj_id, it, pd, EFL_EVENT_CALLBACK_DEL, update_hash)
1270 else EFL_OBJECT_EVENT_CB_INC(obj_id, it, pd, EFL_EVENT_DEL) 1267 else EFL_OBJECT_EVENT_CB_INC(obj_id, it, pd, EFL_EVENT_DEL, update_hash)
1271 else EFL_OBJECT_EVENT_CB_INC(obj_id, it, pd, EFL_EVENT_INVALIDATE) 1268 else EFL_OBJECT_EVENT_CB_INC(obj_id, it, pd, EFL_EVENT_INVALIDATE, update_hash)
1272 else EFL_OBJECT_EVENT_CB_INC(obj_id, it, pd, EFL_EVENT_DESTRUCT) 1269 else EFL_OBJECT_EVENT_CB_INC(obj_id, it, pd, EFL_EVENT_DESTRUCT, update_hash)
1273 else if (it->desc == EFL_EVENT_NOREF && !pd->event_cb_EFL_EVENT_NOREF) 1270 else if (it->desc == EFL_EVENT_NOREF && !pd->event_cb_EFL_EVENT_NOREF)
1274 { 1271 {
1272 update_hash = EINA_FALSE;
1273
1275 if (efl_event_callback_count(obj_id, EFL_EVENT_NOREF) > 0) 1274 if (efl_event_callback_count(obj_id, EFL_EVENT_NOREF) > 0)
1276 { 1275 {
1277 EO_OBJ_POINTER_RETURN(obj_id, obj); 1276 EO_OBJ_POINTER_RETURN(obj_id, obj);
@@ -1287,6 +1286,15 @@ _special_event_count_inc(Eo *obj_id, Efl_Object_Data *pd, const Efl_Callback_Arr
1287 obj->ownership_track = EINA_TRUE; 1286 obj->ownership_track = EINA_TRUE;
1288 EO_OBJ_DONE(obj_id); 1287 EO_OBJ_DONE(obj_id);
1289 } 1288 }
1289
1290 if (update_hash)
1291 {
1292 unsigned char event_hash;
1293
1294 event_hash = _pointer_hash((uintptr_t) it->desc);
1295
1296 pd->callbacks_mask |= 1ULL << event_hash;
1297 }
1290} 1298}
1291 1299
1292static inline void 1300static inline void
@@ -1976,8 +1984,12 @@ _cb_desc_match(const Efl_Event_Description *a, const Efl_Event_Description *b, E
1976 return !strcmp(a->name, b->name); 1984 return !strcmp(a->name, b->name);
1977} 1985}
1978 1986
1979#define EFL_OBJECT_EVENT_CALLBACK_BLOCK(Pd, Desc, Event) \ 1987#define EFL_OBJECT_EVENT_CALLBACK_BLOCK(Pd, Desc, Event, Need_Hash) \
1980 if ((Desc == Event) && (!(Pd->event_cb_##Event))) return EINA_TRUE; 1988 if (Desc == Event) \
1989 { \
1990 if (!(Pd->event_cb_##Event)) return EINA_TRUE; \
1991 Need_Hash = EINA_FALSE; \
1992 } \
1981 1993
1982static inline Eina_Bool 1994static inline Eina_Bool
1983_event_callback_call(Eo *obj_id, Efl_Object_Data *pd, 1995_event_callback_call(Eo *obj_id, Efl_Object_Data *pd,
@@ -1996,18 +2008,20 @@ _event_callback_call(Eo *obj_id, Efl_Object_Data *pd,
1996 .inserted_before = 0, 2008 .inserted_before = 0,
1997 .generation = 1, 2009 .generation = 1,
1998 }; 2010 };
1999 unsigned char event_hash; 2011 Eina_Bool need_hash = EINA_TRUE;
2000 2012
2001 if (pd->callbacks_count == 0) return EINA_TRUE; 2013 if (pd->callbacks_count == 0) return EINA_TRUE;
2002 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_CALLBACK_ADD) 2014 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_CALLBACK_ADD, need_hash)
2003 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_CALLBACK_DEL) 2015 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_CALLBACK_DEL, need_hash)
2004 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_DEL) 2016 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_DEL, need_hash)
2005 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_INVALIDATE) 2017 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_INVALIDATE, need_hash)
2006 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_NOREF) 2018 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_NOREF, need_hash)
2007 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_DESTRUCT) 2019 else EFL_OBJECT_EVENT_CALLBACK_BLOCK(pd, desc, EFL_EVENT_DESTRUCT, need_hash)
2008 2020
2009 if (!legacy_compare) 2021 if (EINA_LIKELY(!legacy_compare && need_hash))
2010 { 2022 {
2023 unsigned char event_hash;
2024
2011 event_hash = _pointer_hash((uintptr_t) desc); 2025 event_hash = _pointer_hash((uintptr_t) desc);
2012 if (!(pd->callbacks_mask & (1ULL << event_hash))) 2026 if (!(pd->callbacks_mask & (1ULL << event_hash)))
2013 return EINA_TRUE; 2027 return EINA_TRUE;