efl_ui_focus_manager_calc: reduce the amount of list operations
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Wed, 21 Nov 2018 19:57:32 +0000 (20:57 +0100)
committerHermet Park <hermetpark@gmail.com>
Wed, 5 Dec 2018 05:37:06 +0000 (14:37 +0900)
it appears that the calculation of the unordered elements can be done a
lot easier here, when checking in the initial for loop for the right
parent safes us two more list walk later on.

Additionally, if all elements in this chain have the right parent, and
the amount of elements is the same as the parent has, then this list can
be used as a full replacement.

Differential Revision: https://phab.enlightenment.org/D7330

src/lib/elementary/efl_ui_focus_manager_calc.c

index 01cb8673ccf005b6c23efd54095f5236df1bc025..9dd444dde641257d40891100e87e586783f6bd1b 100644 (file)
@@ -683,19 +683,21 @@ _efl_ui_focus_manager_calc_update_order(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data
         tmp = eina_hash_find(pd->node_hash, &o);
 
         if (!tmp) continue;
+        if (T(tmp).parent != pnode) continue;
 
         node_order = eina_list_append(node_order, tmp);
      }
-
-   not_ordered = _set_a_without_b(T(pnode).children, node_order);
-   trash = _set_a_without_b(node_order, T(pnode).children);
-   node_order_clean = _set_a_without_b(node_order, trash);
-
-   eina_list_free(node_order);
-   eina_list_free(trash);
-
-   eina_list_free(T(pnode).children);
-   T(pnode).children = eina_list_merge(node_order_clean, not_ordered);
+   if (eina_list_count(node_order) == eina_list_count(T(pnode).children))
+     {
+        eina_list_free(T(pnode).children);
+        T(pnode).children = node_order;
+     }
+   else
+     {
+        not_ordered = _set_a_without_b(T(pnode).children, node_order);
+        eina_list_free(T(pnode).children);
+        T(pnode).children = eina_list_merge(node_order, not_ordered);
+     }
 
    return;
 }