summaryrefslogtreecommitdiff
path: root/src/lib/evas
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2020-01-29 13:19:14 -0500
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-02-05 10:10:56 +0100
commit5ffa495a1b8b4c614ab13d6c00acbc4a6b38c219 (patch)
treed185c26e2e317916c407bc68b37d98a05c9f1f5b /src/lib/evas
parent02b721078afd4b5683e1d76ad33bf0d451f13d67 (diff)
efl/gesture: use array instead of list for garbage gesture objects
this is always a full iteration so we don't actually need a list Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D11241
Diffstat (limited to 'src/lib/evas')
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_manager.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_manager.c b/src/lib/evas/gesture/efl_canvas_gesture_manager.c
index c5fc151390..d596688788 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_manager.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_manager.c
@@ -25,7 +25,7 @@ typedef struct _Efl_Canvas_Gesture_Manager_Data
25 //Keeps track of all current object gestures. 25 //Keeps track of all current object gestures.
26 Eina_List *m_object_gestures; //(List of *object_gesture) 26 Eina_List *m_object_gestures; //(List of *object_gesture)
27 //Lazy deletion of gestures 27 //Lazy deletion of gestures
28 Eina_List *m_gestures_to_delete; 28 Eina_Array *m_gestures_to_delete;
29 //Kepps config values for gesture recognize 29 //Kepps config values for gesture recognize
30 Eina_Hash *m_config; 30 Eina_Hash *m_config;
31 Eina_Bool processing : 1; 31 Eina_Bool processing : 1;
@@ -38,17 +38,14 @@ static Efl_Canvas_Gesture *
38 Efl_Canvas_Gesture_Recognizer *recognizer, const Efl_Event_Description *type); 38 Efl_Canvas_Gesture_Recognizer *recognizer, const Efl_Event_Description *type);
39 39
40static void 40static void
41_cleanup_object(Eina_List *list) 41_cleanup_object(Eina_Array *arr)
42{ 42{
43 Eina_List *l;
44 Eo *obj; 43 Eo *obj;
45 44
46 if (!list) return; 45 if (!eina_array_count(arr)) return;
47 46
48 EINA_LIST_FOREACH(list, l, obj) 47 while ((obj = eina_array_pop(arr)))
49 efl_del(obj); 48 efl_del(obj);
50
51 eina_list_free(list);
52} 49}
53 50
54static void 51static void
@@ -110,7 +107,7 @@ _efl_canvas_gesture_manager_efl_object_constructor(Eo *obj, Efl_Canvas_Gesture_M
110 pd->m_gesture_contex = eina_hash_pointer_new(EINA_FREE_CB(eina_hash_free)); 107 pd->m_gesture_contex = eina_hash_pointer_new(EINA_FREE_CB(eina_hash_free));
111 pd->m_object_events = eina_hash_pointer_new(EINA_FREE_CB(_hash_unref_cb)); 108 pd->m_object_events = eina_hash_pointer_new(EINA_FREE_CB(_hash_unref_cb));
112 pd->m_object_gestures = NULL; 109 pd->m_object_gestures = NULL;
113 pd->m_gestures_to_delete = NULL; 110 pd->m_gestures_to_delete = eina_array_new(1);;
114 111
115 pd->m_config = eina_hash_string_superfast_new(EINA_FREE_CB(eina_value_free)); 112 pd->m_config = eina_hash_string_superfast_new(EINA_FREE_CB(eina_value_free));
116 /* this needs to always be present */ 113 /* this needs to always be present */
@@ -163,6 +160,7 @@ _efl_canvas_gesture_manager_efl_object_destructor(Eo *obj, Efl_Canvas_Gesture_Ma
163 eina_hash_free(pd->m_gesture_contex); 160 eina_hash_free(pd->m_gesture_contex);
164 eina_hash_free(pd->m_object_events); 161 eina_hash_free(pd->m_object_events);
165 _cleanup_object(pd->m_gestures_to_delete); 162 _cleanup_object(pd->m_gestures_to_delete);
163 eina_array_free(pd->m_gestures_to_delete);
166 efl_destructor(efl_super(obj, MY_CLASS)); 164 efl_destructor(efl_super(obj, MY_CLASS));
167} 165}
168 166
@@ -312,7 +310,6 @@ post_event:
312 eina_hash_del(pd->m_object_events, &recognizer, NULL); 310 eina_hash_del(pd->m_object_events, &recognizer, NULL);
313 //FIXME: delete it by object not list. 311 //FIXME: delete it by object not list.
314 _cleanup_object(pd->m_gestures_to_delete); 312 _cleanup_object(pd->m_gestures_to_delete);
315 pd->m_gestures_to_delete = NULL;
316 } 313 }
317} 314}
318 315
@@ -411,14 +408,13 @@ _efl_canvas_gesture_manager_recognizer_unregister(Eo *obj EINA_UNUSED, Efl_Canva
411 { 408 {
412 if ((object_gesture->type == type) && (object_gesture->recognizer == recognizer)) 409 if ((object_gesture->type == type) && (object_gesture->recognizer == recognizer))
413 { 410 {
414 pd->m_gestures_to_delete = eina_list_append(pd->m_gestures_to_delete, object_gesture->gesture); 411 eina_array_push(pd->m_gestures_to_delete, object_gesture->gesture);
415 free(object_gesture); 412 free(object_gesture);
416 pd->m_object_gestures = eina_list_remove_list(pd->m_object_gestures, l); 413 pd->m_object_gestures = eina_list_remove_list(pd->m_object_gestures, l);
417 } 414 }
418 } 415 }
419 if (pd->processing) return; 416 if (pd->processing) return;
420 _cleanup_object(pd->m_gestures_to_delete); 417 _cleanup_object(pd->m_gestures_to_delete);
421 pd->m_gestures_to_delete = NULL;
422} 418}
423 419
424// EOLIAN static void 420// EOLIAN static void
@@ -470,7 +466,6 @@ _get_state(Efl_Canvas_Gesture_Manager_Data *pd,
470 _cleanup_cached_gestures(pd, target, type, recognizer); 466 _cleanup_cached_gestures(pd, target, type, recognizer);
471 eina_hash_del(pd->m_object_events, &recognizer, NULL); 467 eina_hash_del(pd->m_object_events, &recognizer, NULL);
472 _cleanup_object(pd->m_gestures_to_delete); 468 _cleanup_object(pd->m_gestures_to_delete);
473 pd->m_gestures_to_delete = NULL;
474 return NULL; 469 return NULL;
475 } 470 }
476 return object_gesture->gesture; 471 return object_gesture->gesture;
@@ -506,7 +501,7 @@ _cleanup_cached_gestures(Efl_Canvas_Gesture_Manager_Data *pd,
506 if ((object_gesture->type == type) && (target == object_gesture->object) && 501 if ((object_gesture->type == type) && (target == object_gesture->object) &&
507 ((!recognizer) || (object_gesture->recognizer == recognizer))) 502 ((!recognizer) || (object_gesture->recognizer == recognizer)))
508 { 503 {
509 pd->m_gestures_to_delete = eina_list_append(pd->m_gestures_to_delete, object_gesture->gesture); 504 eina_array_push(pd->m_gestures_to_delete, object_gesture->gesture);
510 free(object_gesture); 505 free(object_gesture);
511 pd->m_object_gestures = eina_list_remove_list(pd->m_object_gestures, l); 506 pd->m_object_gestures = eina_list_remove_list(pd->m_object_gestures, l);
512 } 507 }
@@ -522,7 +517,6 @@ efl_gesture_manager_gesture_clean_up(Eo *obj, Eo *target, const Efl_Event_Descri
522 _cleanup_cached_gestures(pd, target, type, recognizer); 517 _cleanup_cached_gestures(pd, target, type, recognizer);
523 eina_hash_del(pd->m_object_events, &recognizer, NULL); 518 eina_hash_del(pd->m_object_events, &recognizer, NULL);
524 _cleanup_object(pd->m_gestures_to_delete); 519 _cleanup_object(pd->m_gestures_to_delete);
525 pd->m_gestures_to_delete = NULL;
526} 520}
527 521
528#include "efl_canvas_gesture_manager.eo.c" 522#include "efl_canvas_gesture_manager.eo.c"