summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-07 17:20:38 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-08-07 17:20:38 +0200
commit0ffc51aee05d507afe4f4d78c39a8c0c86682a10 (patch)
tree311ceba40bc3187c726414c5845ef89912bae319
parent8a8bdd406ae2a05e603152d79d9d583bab905682 (diff)
efl_ui_focus_manager_calc: optimize item deletion
if there is high frequency adding and deleting of items, the deletion here can be quite heavy, this makes freeing a little bit faster.
-rw-r--r--src/lib/elementary/efl_ui_focus_manager_calc.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c b/src/lib/elementary/efl_ui_focus_manager_calc.c
index 29b52f2eb6..3eb90861b3 100644
--- a/src/lib/elementary/efl_ui_focus_manager_calc.c
+++ b/src/lib/elementary/efl_ui_focus_manager_calc.c
@@ -68,6 +68,7 @@ struct _Node{
68 } graph; 68 } graph;
69 69
70 Eina_Bool on_list : 1; 70 Eina_Bool on_list : 1;
71 Eina_Bool unused : 1;
71}; 72};
72 73
73#define T(n) (n->tree) 74#define T(n) (n->tree)
@@ -237,42 +238,49 @@ node_item_free(Node *item)
237 /*cleanup graph parts*/ 238 /*cleanup graph parts*/
238 239
239 //add all neighbors of the node to the dirty list 240 //add all neighbors of the node to the dirty list
240 for(int i = EFL_UI_FOCUS_DIRECTION_UP; i < EFL_UI_FOCUS_DIRECTION_LAST; i++) 241 if (!item->unused)
241 { 242 {
242 Node *partner; 243 for(int i = EFL_UI_FOCUS_DIRECTION_UP; i < EFL_UI_FOCUS_DIRECTION_LAST; i++)
244 {
245 Node *partner;
243 246
244#define MAKE_LIST_DIRTY(node, field) \ 247#define MAKE_LIST_DIRTY(node, field) \
245 EINA_LIST_FOREACH(DIRECTION_ACCESS(node, i).field, l, partner) \ 248 EINA_LIST_FOREACH(DIRECTION_ACCESS(node, i).field, l, partner) \
246 { \
247 if (partner->type != NODE_TYPE_ONLY_LOGICAL) \
248 { \ 249 { \
249 dirty_add(obj, pd, partner); \ 250 if (partner->type != NODE_TYPE_ONLY_LOGICAL) \
250 dirty_added = EINA_TRUE; \ 251 { \
251 } \ 252 dirty_add(obj, pd, partner); \
252 } 253 dirty_added = EINA_TRUE; \
254 } \
255 }
256
257 MAKE_LIST_DIRTY(item, one_direction)
258 MAKE_LIST_DIRTY(item, cleanup_nodes)
253 259
254 MAKE_LIST_DIRTY(item, one_direction) 260 border_onedirection_cleanup(item, i);
255 MAKE_LIST_DIRTY(item, cleanup_nodes) 261 border_onedirection_set(item, i, NULL);
262 }
256 263
257 border_onedirection_cleanup(item, i);
258 border_onedirection_set(item, i, NULL);
259 } 264 }
260 265
261 //the unregistering of a item should ever result in atleast a coords_dirty call 266 //the unregistering of a item should ever result in atleast a coords_dirty call
262 if (!dirty_added) 267 if (dirty_added)
263 efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY, NULL); 268 efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_COORDS_DIRTY, NULL);
264 269
265 /*cleanup manager householdings*/ 270 /*cleanup manager householdings*/
266 271
267 //remove from the focus stack 272 //remove from the focus stack
268 pd->focus_stack = eina_list_remove(pd->focus_stack, item); 273
274 if (!item->unused)
275 pd->focus_stack = eina_list_remove(pd->focus_stack, item);
269 276
270 //if this is the entry for redirect, NULL them out! 277 //if this is the entry for redirect, NULL them out!
271 if (pd->redirect_entry == item->focusable) 278 if (pd->redirect_entry == item->focusable)
272 pd->redirect_entry = NULL; 279 pd->redirect_entry = NULL;
273 280
274 //remove from the dirty parts 281 //remove from the dirty parts
275 pd->dirty = eina_list_remove(pd->dirty, item); 282 if (item->on_list)
283 pd->dirty = eina_list_remove(pd->dirty, item);
276 item->on_list = EINA_FALSE; 284 item->on_list = EINA_FALSE;
277 285
278 /*merge tree items*/ 286 /*merge tree items*/
@@ -375,7 +383,7 @@ dirty_flush_node(Efl_Ui_Focus_Manager *obj EINA_UNUSED, Efl_Ui_Focus_Manager_Cal
375 Efl_Ui_Focus_Graph_Calc_Result result; 383 Efl_Ui_Focus_Graph_Calc_Result result;
376 384
377 efl_ui_focus_graph_calc(&pd->graph_ctx, eina_iterator_filter_new(eina_hash_iterator_data_new(pd->node_hash), _no_logical, NULL, NULL) , (Opaque_Graph_Member*) node, &result); 385 efl_ui_focus_graph_calc(&pd->graph_ctx, eina_iterator_filter_new(eina_hash_iterator_data_new(pd->node_hash), _no_logical, NULL, NULL) , (Opaque_Graph_Member*) node, &result);
378 386 node->unused = EINA_FALSE;
379 for (int i = 0; i < 4; ++i) 387 for (int i = 0; i < 4; ++i)
380 { 388 {
381 Efl_Ui_Focus_Direction direction = -1; 389 Efl_Ui_Focus_Direction direction = -1;
@@ -506,7 +514,7 @@ _register(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd, Efl_Ui_Focus_Object *chil
506 514
507 node = node_new(child, obj); 515 node = node_new(child, obj);
508 eina_hash_add(pd->node_hash, &child, node); 516 eina_hash_add(pd->node_hash, &child, node);
509 517 node->unused = EINA_TRUE;
510 //add the parent 518 //add the parent
511 if (parent) 519 if (parent)
512 { 520 {
@@ -1460,6 +1468,7 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_manager_focus_set(Eo *obj, Efl_U
1460 node = node_get(obj, pd, focus); 1468 node = node_get(obj, pd, focus);
1461 if (!node) return; 1469 if (!node) return;
1462 1470
1471 node->unused = EINA_FALSE;
1463 if (node->type == NODE_TYPE_ONLY_LOGICAL && !node->redirect_manager) 1472 if (node->type == NODE_TYPE_ONLY_LOGICAL && !node->redirect_manager)
1464 { 1473 {
1465 Node *target = NULL; 1474 Node *target = NULL;