elementary: use array instead of list for subchildren 15/226615/2
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Mon, 17 Feb 2020 12:56:06 +0000 (13:56 +0100)
committerJongmin Lee <jm105.lee@samsung.com>
Thu, 5 Mar 2020 09:46:39 +0000 (09:46 +0000)
this safes in the runtime of elm_test round about 9kb (*).
Additionally, using a array here is jumping way fewer times arround in
memory, as we do not need to jump from node to node in a list.

Additionally, this commit replaces a few abort disabler macros with a
error checking macro. (which cleans the log).

*: explanation: we have round about 600 widgets in elm_test, every
widget is normally refered once, every list node has 4 pointer, makes
round about 9600 bytes or rougly 9 KB. So the messured savings are more
or less explaining the reality.

Reviewed-by: Carsten Haitzler (Rasterman) <rasterman.com>
Differential Revision: https://phab.enlightenment.org/D11374

Change-Id: Ib906697a1ba71277e1fbdebedbdc0c05cb44d53a

16 files changed:
src/lib/elementary/efl_ui_layout.c
src/lib/elementary/efl_ui_panel.c
src/lib/elementary/efl_ui_widget.c
src/lib/elementary/efl_ui_widget_common.c
src/lib/elementary/efl_ui_win.c
src/lib/elementary/elm_atspi_bridge.c
src/lib/elementary/elm_box.c
src/lib/elementary/elm_config.c
src/lib/elementary/elm_focus_legacy.c
src/lib/elementary/elm_genlist.c
src/lib/elementary/elm_grid.c
src/lib/elementary/elm_panel.c
src/lib/elementary/elm_table.c
src/lib/elementary/elm_widget.h
src/lib/elementary_tizen/elm_genlist.c
src/tests/elementary/efl_ui_test_widget.c

index e488851..55b3360 100644 (file)
@@ -197,11 +197,13 @@ _sizing_eval(Evas_Object *obj, Efl_Ui_Layout_Data *sd, Elm_Layout_Data *ld)
 
    if (sd->calc_subobjs && !evas_smart_objects_calculating_get(evas_object_evas_get(obj)))
      {
-        Eina_List *l;
         Eo *subobj;
         /* user has manually triggered a smart calc and wants subobjs to also calc */
-        EINA_LIST_FOREACH(wd->subobjs, l, subobj)
-          efl_canvas_group_calculate(subobj);
+        for (unsigned int i = 0; i < eina_array_count(wd->children); ++i)
+          {
+             subobj = eina_array_data_get(wd->children, i);
+             efl_canvas_group_calculate(subobj);
+          }
      }
    elm_coords_finger_size_adjust(sd->finger_size_multiplier_x, &rest_w,
                                  sd->finger_size_multiplier_y, &rest_h);
@@ -1088,8 +1090,6 @@ _efl_ui_layout_base_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Layout_Data *sd)
    Efl_Ui_Layout_Sub_Object_Data *sub_d;
    Efl_Ui_Layout_Sub_Object_Cursor *pc;
    Edje_Signal_Data *esd;
-   Evas_Object *child;
-   Eina_List *l;
    Efl_Model *model;
 
    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
@@ -1155,15 +1155,15 @@ _efl_ui_layout_base_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Layout_Data *sd)
 
    /* let's make our Edje object the *last* to be processed, since it
     * may (smart) parent other sub objects here */
-   EINA_LIST_FOREACH(wd->subobjs, l, child)
-     {
-        if (child == wd->resize_obj)
-          {
-             wd->subobjs =
-               eina_list_demote_list(wd->subobjs, l);
-             break;
-          }
-     }
+   {
+      unsigned int resize_id = 0;
+      if (eina_array_find(wd->children, wd->resize_obj, &resize_id))
+        {
+           //exchange with last
+           eina_array_data_set(wd->children, resize_id, eina_array_data_get(wd->children, eina_array_count(wd->children) - 1));
+           eina_array_data_set(wd->children, eina_array_count(wd->children) - 1, wd->resize_obj);
+        }
+   }
 
    sd->destructed_is = EINA_TRUE;
 
index c173224..212ce3d 100644 (file)
@@ -886,9 +886,6 @@ _efl_ui_panel_efl_object_constructor(Eo *obj, Efl_Ui_Panel_Data *_pd)
 EOLIAN static void
 _efl_ui_panel_efl_object_destructor(Eo *obj, Efl_Ui_Panel_Data *sd)
 {
-   Evas_Object *child;
-   Eina_List *l;
-
    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
 
    sd->delete_me = EINA_TRUE;
@@ -897,15 +894,15 @@ _efl_ui_panel_efl_object_destructor(Eo *obj, Efl_Ui_Panel_Data *sd)
 
    /* let's make our panel object the *last* to be processed, since it
     * may (smart) parent other sub objects here */
-   EINA_LIST_FOREACH(wd->subobjs, l, child)
-     {
-        if (child == sd->bx)
-          {
-             wd->subobjs =
-               eina_list_demote_list(wd->subobjs, l);
-             break;
-          }
-     }
+   {
+      unsigned int resize_id = 0;
+      if (eina_array_find(wd->children, wd->resize_obj, &resize_id))
+        {
+           //exchange with last
+           eina_array_data_set(wd->children, resize_id, eina_array_data_get(wd->children, eina_array_count(wd->children) - 1));
+           eina_array_data_set(wd->children, eina_array_count(wd->children) - 1, wd->resize_obj);
+        }
+   }
 
    efl_destructor(efl_super(obj, MY_CLASS));
 }
index 38c17fd..edccefa 100644 (file)
@@ -835,6 +835,14 @@ _efl_ui_widget_efl_canvas_group_group_add(Eo *obj, Elm_Widget_Smart_Data *priv)
                                   _obj_mouse_in, obj);
 }
 
+static Eina_Bool
+_keep(void *data, void *gdata)
+{
+   if (data == gdata)
+     return EINA_FALSE;
+   return EINA_TRUE;
+}
+
 EOLIAN static void
 _efl_ui_widget_efl_canvas_group_group_del(Eo *obj, Elm_Widget_Smart_Data *sd)
 {
@@ -848,20 +856,18 @@ _efl_ui_widget_efl_canvas_group_group_del(Eo *obj, Elm_Widget_Smart_Data *sd)
         _callbacks_del(sd->hover_obj, obj);
         sd->hover_obj = NULL;
      }
-
-   while (sd->subobjs)
+   while(eina_array_count(sd->children))
      {
-        sobj = eina_list_data_get(sd->subobjs);
+        sobj = eina_array_data_get(sd->children, 0);
 
-        /* let the objects clean-up themselves and get rid of this list */
         if (!elm_widget_sub_object_del(obj, sobj))
           {
              ERR("failed to remove sub object %p from %p\n", sobj, obj);
-             sd->subobjs = eina_list_remove_list
-                 (sd->subobjs, sd->subobjs);
+             eina_array_remove(sd->children, _keep, sobj);
           }
         // FIXME: is that a legacy or a new object ?
         evas_object_del(sobj);
+        EINA_SAFETY_ON_TRUE_RETURN(eina_array_count(sd->children) && sobj == eina_array_data_get(sd->children, 0));
      }
    sd->tooltips = eina_list_free(sd->tooltips); /* should be empty anyway */
    sd->cursors = eina_list_free(sd->cursors); /* should be empty anyway */
@@ -962,14 +968,14 @@ _elm_widget_full_eval_children(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd EI
    //TIZEN_ONLY(20180607): Restore legacy focus
    return;
    /*
-   Eina_List *l;
    Eo *child;
 
    _full_eval(obj, sd);
 
-   EINA_LIST_FOREACH(sd->subobjs , l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
         Elm_Widget_Smart_Data *sd_child;
+        child = eina_array_data_get(sd->children, i);
 
         if (!efl_isa(child, EFL_UI_WIDGET_CLASS)) continue;
 
@@ -1086,12 +1092,13 @@ EOLIAN static void
 _efl_ui_widget_efl_canvas_object_is_frame_object_set(Eo *obj, Elm_Widget_Smart_Data *pd, Eina_Bool frame)
 {
    Evas_Object *o;
-   Eina_List *li;
 
    frame = !!frame;
    efl_canvas_object_is_frame_object_set(efl_super(obj, MY_CLASS), frame);
-   EINA_LIST_FOREACH(pd->subobjs, li, o)
+   for (unsigned int i = 0; i < eina_array_count(pd->children); ++i)
      {
+        o = eina_array_data_get(pd->children, i);
+
        if (evas_object_data_get(o, "_elm_leaveme")) continue;
        efl_canvas_object_is_frame_object_set(o, frame);
      }
@@ -1340,13 +1347,14 @@ EAPI Eina_Bool
 elm_widget_access(Evas_Object *obj,
                   Eina_Bool is_access)
 {
-   const Eina_List *l;
    Evas_Object *child;
    Eina_Bool ret = EINA_TRUE;
 
    API_ENTRY return EINA_FALSE;
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
+
         if (elm_widget_is(child))
           ret &= elm_widget_access(child, is_access);
      }
@@ -1382,10 +1390,12 @@ elm_widget_theme(Evas_Object *obj)
    Eina_Bool err_generic = EINA_FALSE;
 
    API_ENTRY return EFL_UI_THEME_APPLY_ERROR_GENERIC;
-
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
-     if (_elm_widget_is(child))
-       _elm_widget_theme_helper(elm_widget_theme(child), &err_default, &err_generic);
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
+     {
+        child = eina_array_data_get(sd->children, i);
+        if (_elm_widget_is(child))
+          _elm_widget_theme_helper(elm_widget_theme(child), &err_default, &err_generic);
+     }
 
    if (sd->hover_obj)
      _elm_widget_theme_helper(elm_widget_theme(sd->hover_obj), &err_default, &err_generic);
@@ -1433,8 +1443,9 @@ elm_widget_theme_specific(Evas_Object *obj,
           }
      }
    if (!force) return;
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
         if (elm_widget_is(child))
           elm_widget_theme_specific(child, th, force);
      }
@@ -1592,7 +1603,7 @@ _efl_ui_widget_widget_parent_set(Eo *obj, Elm_Widget_Smart_Data *pd, Efl_Ui_Widg
    if (parent)
      {
         ELM_WIDGET_DATA_GET_OR_RETURN(parent, ppd);
-        EINA_SAFETY_ON_FALSE_RETURN(eina_list_data_find(ppd->subobjs, obj));
+        EINA_SAFETY_ON_FALSE_RETURN(eina_array_find(ppd->children, obj, NULL));
         if (ppd->parent_obj == parent)
           {
              CRI("ATTEMPTING TO SET CHILD OF PARENT AS PARENT OF ITS OWN PARENT. THIS IS A BUG.");
@@ -1658,7 +1669,8 @@ _efl_ui_widget_widget_parent_set(Eo *obj, Elm_Widget_Smart_Data *pd, Efl_Ui_Widg
 static void
 _widget_add_sub(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
 {
-   sd->subobjs = eina_list_append(sd->subobjs, sobj);
+   if (!sd->children) sd->children = eina_array_new(1);
+   eina_array_push(sd->children, sobj);
    evas_object_data_set(sobj, "elm-parent", obj);
    //TIZEN_ONLY(20181024): Fix parent-children incosistencies in atspi tree
    if (efl_isa(sobj, EFL_ACCESS_OBJECT_MIXIN))
@@ -1670,7 +1682,7 @@ _widget_add_sub(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
 static void
 _widget_del_sub(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Object *sobj)
 {
-   sd->subobjs = eina_list_remove(sd->subobjs, sobj);
+   eina_array_remove(sd->children, _keep, sobj);
    evas_object_data_del(sobj, "elm-parent");
    _callbacks_del(sobj, obj);
 }
@@ -1800,14 +1812,14 @@ _efl_ui_widget_widget_sub_object_del(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob
               * focusable child is gone */
              while (parent)
                {
-                  const Eina_List *l;
                   Evas_Object *subobj;
 
                   ELM_WIDGET_DATA_GET(parent, sdp);
 
                   sdp->child_can_focus = EINA_FALSE;
-                  EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
+                  for (unsigned int i = 0; i < eina_array_count(sdp->children); ++i)
                     {
+                       subobj = eina_array_data_get(sdp->children, i);
                        if ((subobj != sobj) && (_is_focusable(subobj)))
                          {
                             sdp->child_can_focus = EINA_TRUE;
@@ -1953,14 +1965,14 @@ _efl_ui_widget_focus_allow_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool can
         Evas_Object *parent = elm_widget_parent_get(obj);
         while (parent)
           {
-             const Eina_List *l;
              Evas_Object *subobj;
 
              ELM_WIDGET_DATA_GET(parent, sdp);
 
              sdp->child_can_focus = EINA_FALSE;
-             EINA_LIST_FOREACH(sdp->subobjs, l, subobj)
+             for (unsigned int i = 0; i < eina_array_count(sdp->children); ++i)
                {
+                  subobj = eina_array_data_get(sdp->children, i);
                   if (_is_focusable(subobj))
                     {
                        sdp->child_can_focus = EINA_TRUE;
@@ -2026,7 +2038,6 @@ elm_widget_tree_unfocusable_set(Eo *obj, Eina_Bool tree_unfocusable)
 {
    /* TIZEN_ONLY(20190821): keep legacy focus logic
    Efl_Ui_Widget *subs;
-   Eina_List *n;
    Elm_Widget_Smart_Data *pd = efl_data_scope_safe_get(obj, MY_CLASS);
    EINA_SAFETY_ON_NULL_RETURN(pd);
    int distance, parent_counter = (pd->parent_obj ? _tree_unfocusable_counter_get(pd->parent_obj) : 0);
@@ -2043,9 +2054,9 @@ elm_widget_tree_unfocusable_set(Eo *obj, Eina_Bool tree_unfocusable)
         distance = MAX(MIN(tree_unfocusable, 1), 0);
         pd->tree_unfocusable = parent_counter + distance;
      }
-
-   EINA_LIST_FOREACH(pd->subobjs, n, subs)
+   for (unsigned int i = 0; i < eina_array_count(pd->children); ++i)
      {
+        subs = eina_array_data_get(pd->children, i);
         if (efl_isa(subs, EFL_UI_WIDGET_CLASS))
           elm_widget_tree_unfocusable_set(subs, elm_widget_tree_unfocusable_get(obj));
      }
@@ -2116,13 +2127,13 @@ EAPI Eina_List*
 elm_widget_can_focus_child_list_get(const Eo *obj)
 {
    Elm_Widget_Smart_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
-   const Eina_List *l;
    Eina_List *child_list = NULL;
    Evas_Object *child;
 
    if (!sd) return NULL;
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
         if (!_elm_widget_is(child)) continue;
         if ((elm_widget_can_focus_get(child)) &&
             (evas_object_visible_get(child)) &&
@@ -2234,11 +2245,11 @@ EOLIAN static Evas_Object*
 _efl_ui_widget_focused_object_get(const Eo *obj, Elm_Widget_Smart_Data *sd)
 {
    const Evas_Object *subobj;
-   const Eina_List *l;
 
    if (!sd->focused || !sd->top_win_focused) return NULL;
-   EINA_LIST_FOREACH(sd->subobjs, l, subobj)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        subobj = eina_array_data_get(sd->children, i);
         Evas_Object *fobj;
         if (!_elm_widget_is(subobj)) continue;
         fobj = efl_ui_widget_focused_object_get(subobj);
@@ -2766,13 +2777,13 @@ void
 _elm_widget_top_win_focused_set(Evas_Object *obj,
                                 Eina_Bool top_win_focused)
 {
-   const Eina_List *l;
    Evas_Object *child;
    API_ENTRY return;
 
    if (sd->top_win_focused == top_win_focused) return;
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
         if (elm_widget_is(child))
           _elm_widget_top_win_focused_set(child, top_win_focused);
      }
@@ -2793,7 +2804,6 @@ EOLIAN static void
 _efl_ui_widget_disabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina_Bool disabled)
 {
    Efl_Ui_Widget *subs;
-   Eina_List *n;
    int distance, parent_counter = (pd->parent_obj ? _disabled_counter_get(pd->parent_obj) : 0);
 
    if (disabled)
@@ -2812,8 +2822,9 @@ _efl_ui_widget_disabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina
    //TIZEN_ONLY(20191028): Restore focus revert in disabled_set
    efl_ui_widget_focus_disabled_handle(obj);
    //
-   EINA_LIST_FOREACH(pd->subobjs, n, subs)
+   for (unsigned int i = 0; i < eina_array_count(pd->children); ++i)
      {
+        subs = eina_array_data_get(pd->children, i);
         //TIZEN_ONLY(20180607): Restore legacy focus
         if (elm_widget_is(subs))
           efl_ui_widget_focus_disabled_handle((Evas_Object *)subs);
@@ -2874,10 +2885,10 @@ _efl_ui_widget_scroll_hold_push(Eo *obj, Elm_Widget_Smart_Data *sd)
         else
           {
              Evas_Object *child;
-             Eina_List *l;
 
-             EINA_LIST_FOREACH(sd->subobjs, l, child)
+             for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
                {
+                  child = eina_array_data_get(sd->children, i);
                   if (elm_widget_is(child) && _elm_scrollable_is(child))
                     {
                        if (elm_widget_is_legacy(child))
@@ -2908,10 +2919,10 @@ _efl_ui_widget_scroll_hold_pop(Eo *obj, Elm_Widget_Smart_Data *sd)
         else
           {
              Evas_Object *child;
-             Eina_List *l;
 
-             EINA_LIST_FOREACH(sd->subobjs, l, child)
+             for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
                {
+                  child = eina_array_data_get(sd->children, i);
                   if (elm_widget_is(child) && _elm_scrollable_is(child))
                     {
                        if (elm_widget_is_legacy(child))
@@ -2951,10 +2962,10 @@ _efl_ui_widget_scroll_freeze_push(Eo *obj, Elm_Widget_Smart_Data *sd)
         else
           {
              Evas_Object *child;
-             Eina_List *l;
 
-             EINA_LIST_FOREACH(sd->subobjs, l, child)
+             for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
                {
+                  child = eina_array_data_get(sd->children, i);
                   if (elm_widget_is(child) && _elm_scrollable_is(child))
                     {
                        if (elm_widget_is_legacy(child))
@@ -2985,10 +2996,11 @@ _efl_ui_widget_scroll_freeze_pop(Eo *obj, Elm_Widget_Smart_Data *sd)
         else
           {
              Evas_Object *child;
-             Eina_List *l;
 
-             EINA_LIST_FOREACH(sd->subobjs, l, child)
+             for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
                {
+                  child = eina_array_data_get(sd->children, i);
+
                   if (elm_widget_is(child) && _elm_scrollable_is(child))
                     {
                        if (elm_widget_is_legacy(child))
@@ -3226,13 +3238,14 @@ elm_widget_part_translatable_text_get(const Eo *obj, const char *part, const cha
 EOLIAN static void
 _efl_ui_widget_efl_ui_l10n_translation_update(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
 {
-   const Eina_List *l;
    Evas_Object *child;
 
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
         if (elm_widget_is(child))
           efl_ui_l10n_translation_update(child);
+
      }
 
    if (sd->hover_obj) efl_ui_l10n_translation_update(sd->hover_obj);
@@ -3269,13 +3282,13 @@ EAPI Eina_Bool
 elm_widget_screen_reader(Evas_Object *obj,
                   Eina_Bool is_screen_reader)
 {
-   const Eina_List *l;
    Evas_Object *child;
    Eina_Bool ret = EINA_TRUE;
 
    API_ENTRY return EINA_FALSE;
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
         if (elm_widget_is(child))
           ret &= elm_widget_screen_reader(child, is_screen_reader);
      }
@@ -3643,15 +3656,16 @@ elm_widget_type_check(const Evas_Object *obj,
 EAPI Evas_Object *
 elm_widget_name_find(const Eo *obj, const char *name, int recurse)
 {
-   Eina_List *l;
    Evas_Object *child;
    const char *s;
    INTERNAL_ENTRY NULL;
 
    if (!name) return NULL;
    if (!_elm_widget_is(obj)) return NULL;
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
+
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
         s = evas_object_name_get(child);
         if ((s) && (!strcmp(s, name))) return child;
         if ((recurse != 0) &&
@@ -3906,7 +3920,6 @@ elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode)
 {
    Evas_Display_Mode prev_dispmode;
    Evas_Object *child;
-   Eina_List *l;
 
    API_ENTRY return;
    prev_dispmode = evas_object_size_hint_display_mode_get(obj);
@@ -3916,8 +3929,9 @@ elm_widget_display_mode_set(Evas_Object *obj, Evas_Display_Mode dispmode)
 
    evas_object_size_hint_display_mode_set(obj, dispmode);
 
-   EINA_LIST_FOREACH (sd->subobjs, l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
         if (elm_widget_is(child))
           elm_widget_display_mode_set(child, dispmode);
      }
@@ -5568,8 +5582,11 @@ _sub_obj_tree_dump(const Evas_Object *obj,
         DBG("+ %s(%p)\n",
             elm_widget_type_get(obj),
             obj);
-        EINA_LIST_FOREACH(sd->subobjs, l, obj)
+       for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
+         {
+            obj = eina_array_data_get(sd->children, i);
           _sub_obj_tree_dump(obj, lvl + 1);
+         }
      }
    else
      DBG("+ %s(%p)\n", evas_object_type_get(obj), obj);
@@ -5620,8 +5637,12 @@ _sub_obj_tree_dot_dump(const Evas_Object *obj,
 
    Eina_List *l;
    Evas_Object *o;
-   EINA_LIST_FOREACH(sd->subobjs, l, o)
-     _sub_obj_tree_dot_dump(o, output);
+
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
+     {
+        o = eina_array_data_get(sd->children, i);
+        _sub_obj_tree_dot_dump(o, output);
+     }
 }
 
 #endif
@@ -5906,8 +5927,9 @@ _efl_ui_widget_efl_access_object_access_children_get(const Eo *obj EINA_UNUSED,
    Evas_Object *widget;
    Eo *proxy = NULL;
 
-   EINA_LIST_FOREACH(pd->subobjs, l, widget)
+   for (unsigned int i = 0; i < eina_array_count(pd->children); ++i)
      {
+        widget = eina_array_data_get(pd->children, i);
         const char *type = evas_object_type_get(widget);
         // TIZEN ONLY
         // Ugly Tizen hack to integrate AT-SPI2 accessibility provided by WebKit/Chromium with elementary one.
@@ -5917,8 +5939,10 @@ _efl_ui_widget_efl_access_object_access_children_get(const Eo *obj EINA_UNUSED,
              elm_atspi_ewk_wrapper_a11y_init((Eo *)obj, widget);
           }
      }
-   EINA_LIST_FOREACH(pd->subobjs, l, widget)
+   for (unsigned int i = 0; i < eina_array_count(pd->children); ++i)
      {
+        widget = eina_array_data_get(pd->children, i);
+
         // TIZEN_ONLY(20160705) - enable atspi_proxy to work
         /* This assumes that only one proxy exists in obj */
         if (!proxy)
@@ -7622,14 +7646,14 @@ elm_widget_atspi_plug_type_proxy_get(Evas_Object *obj)
 {
    Elm_Widget_Smart_Data *wd;
    Evas_Object *widget;
-   Eina_List *l;
 
    wd = efl_data_scope_get(obj, EFL_UI_WIDGET_CLASS);
    if (!wd) return NULL;
 
    Eo *proxy = NULL;
-   EINA_LIST_FOREACH(wd->subobjs, l, widget)
+   for (unsigned int i = 0; i < eina_array_count(wd->children); ++i)
      {
+        widget = eina_array_data_get(wd->children, i);
         proxy = plug_type_proxy_get(obj, widget);
         if (proxy) break;
      }
@@ -7714,7 +7738,6 @@ _efl_ui_widget_focus_order_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data
 EOLIAN static Evas_Object*
 _efl_ui_widget_newest_focus_order_get(const Eo *obj, Elm_Widget_Smart_Data *sd, unsigned int *newest_focus_order, Eina_Bool can_focus_only)
 {
-   const Eina_List *l;
    Evas_Object *child, *cur, *best;
 
    if (!evas_object_visible_get(obj)
@@ -7731,8 +7754,9 @@ _efl_ui_widget_newest_focus_order_get(const Eo *obj, Elm_Widget_Smart_Data *sd,
              best = (Evas_Object *)obj;
           }
      }
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
         if (!_elm_widget_is(child)) continue;
 
         cur = efl_ui_widget_newest_focus_order_get
@@ -7890,12 +7914,12 @@ _elm_widget_focus_move_policy_reload(Evas_Object *obj)
 EOLIAN static void
 _efl_ui_widget_focus_reconfigure(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED)
 {
-   const Eina_List *l;
    Evas_Object *child;
    API_ENTRY return;
 
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
         if (elm_widget_is(child))
           efl_ui_widget_focus_reconfigure(child);
      }
@@ -8719,12 +8743,12 @@ static void
 _efl_ui_widget_efl_canvas_object_paragraph_direction_set_internal(Eo *obj EINA_UNUSED, Efl_Ui_Widget_Data *sd, Efl_Text_Bidirectional_Type dir)
 {
    Evas_Object *child;
-   Eina_List *l;
 
    if (sd->on_destroy) return;
 
-   EINA_LIST_FOREACH(sd->subobjs, l, child)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        child = eina_array_data_get(sd->children, i);
         if (_elm_widget_is(child))
           {
              Efl_Ui_Widget_Data *sdc = efl_data_scope_get(child, MY_CLASS);
@@ -9380,10 +9404,10 @@ _if_focused_revert(Evas_Object *obj,
                          efl_ui_widget_focused_object_clear(sd2->resize_obj);
                        else
                          {
-                            const Eina_List *l;
                             Evas_Object *child;
-                            EINA_LIST_FOREACH(sd2->subobjs, l, child)
+                            for (unsigned int i = 0; i < eina_array_count(sd2->children); ++i)
                               {
+                                 child = eina_array_data_get(sd2->children, i);
                                  if (!_elm_widget_is(child)) continue;
                                  if (_is_focused(child))
                                    {
@@ -10181,11 +10205,11 @@ elm_widget_focus_set(Eo *obj, Eina_Bool focus)
           }
         else
           {
-             const Eina_List *l;
              Evas_Object *child;
 
-             EINA_LIST_FOREACH(sd->subobjs, l, child)
+             for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
                {
+                  child = eina_array_data_get(sd->children, i);
                   if (!_elm_widget_is(child)) continue;
                   if ((_is_focusable(child)) &&
                        (!elm_widget_disabled_get(child)))
@@ -10198,11 +10222,11 @@ elm_widget_focus_set(Eo *obj, Eina_Bool focus)
      }
    else
      {
-        const Eina_List *l;
         Evas_Object *child;
 
-        EINA_LIST_REVERSE_FOREACH(sd->subobjs, l, child)
+        for (unsigned int i = eina_array_count(sd->children) - 1; i >= 0; i--)
           {
+             child = eina_array_data_get(sd->children, i);
              if (!_elm_widget_is(child)) continue;
              if ((_is_focusable(child)) &&
                  (!elm_widget_disabled_get(child)))
@@ -10224,10 +10248,10 @@ _focused_object_clear(Elm_Widget_Smart_Data *sd)
      }
    else
      {
-        const Eina_List *l;
         Evas_Object *child;
-        EINA_LIST_FOREACH(sd->subobjs, l, child)
+        for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
           {
+             child = eina_array_data_get(sd->children, i);
              if (_elm_widget_is(child) && _is_focused(child))
                {
                   efl_ui_widget_focused_object_clear(child);
index c83fd07..97313e2 100644 (file)
@@ -61,13 +61,14 @@ static Efl_Ui_Widget*
 _next_widget(Efl_Gfx_Entity* o)
 {
    Efl_Ui_Widget *parent;
-   Eina_List *rel;
 
    parent = _fetch_parent_widget(o);
    ELM_WIDGET_DATA_GET_OR_RETURN(parent, pd, NULL);
-   rel = eina_list_data_find_list(pd->subobjs, o);
-
-   return eina_list_data_get(eina_list_next(rel));
+   unsigned int id;
+   if (eina_array_find(pd->children, o, &id) && id + 1 < eina_array_count(pd->children))
+     return eina_array_data_get(pd->children, id + 1);
+   else
+     return NULL;
 }
 
 static Eina_Bool
@@ -90,9 +91,9 @@ _widget_next(Widget_Iterator *it, void **data)
      }
 
    //If there is a child, go there
-   if (pd && pd->subobjs)
+   if (pd && eina_array_count(pd->children))
      {
-        it->current = eina_list_data_get(pd->subobjs);
+        it->current = eina_array_data_get(pd->children, 0);
         goto deliver;
      }
 
index 68166ae..c0e9a9f 100644 (file)
@@ -2337,11 +2337,12 @@ _efl_ui_win_efl_ui_widget_focus_next(Eo *obj, Efl_Ui_Win_Data *_pd EINA_UNUSED,
    void *(*list_data_get)(const Eina_List *list);
 
    /* Focus chain */
-   if (wd->subobjs)
+   if (wd->children)
      {
         if (!(items = efl_ui_widget_focus_custom_chain_get(obj)))
           {
-             items = wd->subobjs;
+             for (unsigned int i = 0; i < eina_array_count(wd->children); ++i)
+               items = eina_list_append((Eina_List *)items, eina_array_data_get(wd->children, i));
              if (!items)
                return EINA_FALSE;
           }
@@ -2370,10 +2371,13 @@ _efl_ui_win_efl_ui_widget_focus_direction(Eo *obj, Efl_Ui_Win_Data *_pd EINA_UNU
    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
 
    /* Focus chain */
-   if (wd->subobjs)
+   if (wd->children)
      {
         if (!(items = efl_ui_widget_focus_custom_chain_get(obj)))
-          items = wd->subobjs;
+          {
+             for (unsigned int i = 0; i < eina_array_count(wd->children); ++i)
+               items = eina_list_append((Eina_List *)items, eina_array_data_get(wd->children, i));
+          }
 
         list_data_get = eina_list_data_get;
 
index 0685029..6bf42d9 100644 (file)
@@ -1118,11 +1118,11 @@ _accessible_get_navigable_at_point(const Eldbus_Service_Interface *iface EINA_UN
         wd = efl_data_scope_get(parent, EFL_UI_WIDGET_CLASS);
         if (wd)
           {
-             Eina_List *l;
              Evas_Object *widget;
 
-             EINA_LIST_FOREACH(wd->subobjs, l, widget)
+             for (unsigned int i = 0; i < eina_array_count(wd->children); ++i)
                {
+                  widget = eina_array_data_get(wd->children, i);
                   // TIZEN_ONLY(20171109) : fix for invalid proxy object, when at-spi has been restarted
                   Eo *proxy = plug_type_proxy_get(parent, widget);
                   //
index 83654d6..190f7dd 100644 (file)
@@ -404,9 +404,6 @@ _elm_box_efl_canvas_group_group_add(Eo *obj, Elm_Box_Data *_pd EINA_UNUSED)
 EOLIAN static void
 _elm_box_efl_canvas_group_group_del(Eo *obj, Elm_Box_Data *sd)
 {
-   Eina_List *l;
-   Evas_Object *child;
-
    sd->delete_me = EINA_TRUE;
 
    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
@@ -416,15 +413,15 @@ _elm_box_efl_canvas_group_group_del(Eo *obj, Elm_Box_Data *sd)
 
    /* let's make our box object the *last* to be processed, since it
     * may (smart) parent other sub objects here */
-   EINA_LIST_FOREACH (wd->subobjs, l, child)
-     {
-        if (child == wd->resize_obj)
-          {
-             wd->subobjs =
-               eina_list_demote_list(wd->subobjs, l);
-             break;
-          }
-     }
+   {
+      unsigned int resize_id = 0;
+      if (eina_array_find(wd->children, wd->resize_obj, &resize_id))
+        {
+           //exchange with last
+           eina_array_data_set(wd->children, resize_id, eina_array_data_get(wd->children, eina_array_count(wd->children) - 1));
+           eina_array_data_set(wd->children, eina_array_count(wd->children) - 1, wd->resize_obj);
+        }
+   }
 
    efl_canvas_group_del(efl_super(obj, MY_CLASS));
 }
index ed31075..f21ab24 100644 (file)
@@ -4230,7 +4230,6 @@ _efl_ui_widget_config_reload(Efl_Ui_Widget *obj)
    Elm_Focus_Move_Policy focus_move_policy = elm_config_focus_move_policy_get();
    ELM_WIDGET_DATA_GET_OR_RETURN(obj, sd);
    Efl_Ui_Widget *w;
-   Eina_List *n;
 
    //reload focus move policy
    if (efl_ui_widget_focus_move_policy_automatic_get(obj) &&
@@ -4239,8 +4238,9 @@ _efl_ui_widget_config_reload(Efl_Ui_Widget *obj)
         sd->focus_move_policy = focus_move_policy;
      }
 
-   EINA_LIST_FOREACH(sd->subobjs, n, w)
+   for (unsigned int i = 0; i < eina_array_count(sd->children); ++i)
      {
+        w = eina_array_data_get(sd->children, i);
         if (efl_isa(w, EFL_UI_WIDGET_CLASS))
           _efl_ui_widget_config_reload(w);
      }
index 82a3624..d64cf95 100644 (file)
@@ -51,12 +51,18 @@ _flush_manager(Efl_Ui_Widget *obj, Elm_Widget_Smart_Data *pd)
    manager = efl_ui_focus_object_focus_manager_get(obj);
    if (manager)
      {
-        Eina_List *order;
+        Eina_List *order = NULL;
 
         if (pd->legacy_focus.custom_chain)
           order = eina_list_clone(pd->legacy_focus.custom_chain);
         else
-          order = eina_list_clone(pd->subobjs);
+          {
+             for (unsigned int i = 0; i < eina_array_count(pd->children); ++i)
+               {
+                  Eo *sobj = eina_array_data_get(pd->children, i);
+                  order = eina_list_append(order, sobj);
+               }
+          }
 
         efl_ui_focus_manager_calc_update_order(manager, obj, order);
      }
index 023ed9c..7da18d0 100644 (file)
@@ -408,7 +408,6 @@ static void
 _widget_calculate_recursive(Eo *obj)
 {
    Elm_Widget_Smart_Data *pd = NULL;
-   Eina_List *l;
    Evas_Object *child;
 
    if (!efl_isa(obj, EFL_UI_WIDGET_CLASS)) return;
@@ -424,8 +423,11 @@ _widget_calculate_recursive(Eo *obj)
           return;
      }
 
-   EINA_LIST_FOREACH(pd->subobjs, l, child)
-     _widget_calculate_recursive(child);
+   for (unsigned int i = 0; i < eina_array_count(pd->children); ++i)
+     {
+        child = eina_array_data_get(pd->children, i);
+        _widget_calculate_recursive(child);
+     }
 
    efl_canvas_group_calculate(obj);
 }
index 93d60fd..3cc4263 100644 (file)
@@ -156,22 +156,19 @@ _elm_grid_efl_canvas_group_group_add(Eo *obj, void *_pd EINA_UNUSED)
 EOLIAN static void
 _elm_grid_efl_canvas_group_group_del(Eo *obj, void *_pd EINA_UNUSED)
 {
-   Eina_List *l;
-   Evas_Object *child;
-
    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
 
    /* let's make our grid object the *last* to be processed, since it
     * may (smart) parent other sub objects here */
-   EINA_LIST_FOREACH(wd->subobjs, l, child)
-     {
-        if (child == wd->resize_obj)
-          {
-             wd->subobjs =
-               eina_list_demote_list(wd->subobjs, l);
-             break;
-          }
-     }
+   {
+      unsigned int resize_id = 0;
+      if (eina_array_find(wd->children, wd->resize_obj, &resize_id))
+        {
+           //exchange with last
+           eina_array_data_set(wd->children, resize_id, eina_array_data_get(wd->children, eina_array_count(wd->children) - 1));
+           eina_array_data_set(wd->children, eina_array_count(wd->children) - 1, wd->resize_obj);
+        }
+   }
 
    efl_canvas_group_del(efl_super(obj, MY_CLASS));
 }
index edf2f92..11c1ebe 100644 (file)
@@ -1032,9 +1032,6 @@ _elm_panel_efl_canvas_group_group_add(Eo *obj, Elm_Panel_Data *priv)
 EOLIAN static void
 _elm_panel_efl_canvas_group_group_del(Eo *obj, Elm_Panel_Data *sd)
 {
-   Evas_Object *child;
-   Eina_List *l;
-
    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
 
    sd->delete_me = EINA_TRUE;
@@ -1043,15 +1040,15 @@ _elm_panel_efl_canvas_group_group_del(Eo *obj, Elm_Panel_Data *sd)
 
    /* let's make our panel object the *last* to be processed, since it
     * may (smart) parent other sub objects here */
-   EINA_LIST_FOREACH(wd->subobjs, l, child)
-     {
-        if (child == sd->bx)
-          {
-             wd->subobjs =
-               eina_list_demote_list(wd->subobjs, l);
-             break;
-          }
-     }
+   {
+      unsigned int resize_id = 0;
+      if (eina_array_find(wd->children, wd->resize_obj, &resize_id))
+        {
+           //exchange with last
+           eina_array_data_set(wd->children, resize_id, eina_array_data_get(wd->children, eina_array_count(wd->children) - 1));
+           eina_array_data_set(wd->children, eina_array_count(wd->children) - 1, wd->resize_obj);
+        }
+   }
 
    efl_canvas_group_del(efl_super(obj, MY_CLASS));
 }
index b19e9f1..d89729d 100644 (file)
@@ -193,9 +193,6 @@ _elm_table_efl_canvas_group_group_add(Eo *obj, void *_pd EINA_UNUSED)
 EOLIAN static void
 _elm_table_efl_canvas_group_group_del(Eo *obj, void *_pd EINA_UNUSED)
 {
-   Eina_List *l;
-   Evas_Object *child;
-
    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
 
    evas_object_event_callback_del_full
@@ -204,15 +201,15 @@ _elm_table_efl_canvas_group_group_del(Eo *obj, void *_pd EINA_UNUSED)
 
    /* let's make our table object the *last* to be processed, since it
     * may (smart) parent other sub objects here */
-   EINA_LIST_FOREACH(wd->subobjs, l, child)
-     {
-        if (child == wd->resize_obj)
-          {
-             wd->subobjs =
-               eina_list_demote_list(wd->subobjs, l);
-             break;
-          }
-     }
+   {
+      unsigned int resize_id = 0;
+      if (eina_array_find(wd->children, wd->resize_obj, &resize_id))
+        {
+           //exchange with last
+           eina_array_data_set(wd->children, resize_id, eina_array_data_get(wd->children, eina_array_count(wd->children) - 1));
+           eina_array_data_set(wd->children, eina_array_count(wd->children) - 1, wd->resize_obj);
+        }
+   }
 
    efl_canvas_group_del(efl_super(obj, MY_CLASS));
 }
index 052f0d7..5e8c499 100644 (file)
@@ -336,7 +336,7 @@ typedef void * (*list_data_get_func_type)(const Eina_List * l);
 typedef struct _Elm_Widget_Smart_Data
 {
    Evas_Object                  *parent_obj; /**< parent object of a widget in the elementary tree */
-   Eina_List                    *subobjs; /**< list of widgets' sub objects in the elementary tree */
+   Eina_Array                   *children;
    Evas_Object                  *resize_obj; /**< an unique object for each widget that shows the look of a widget. Resize object's geometry is same as the widget. This resize object is different from that of window's resize object. */
    Evas_Object                  *hover_obj;
    Evas_Object                  *bg;
index 9cbb468..1bcc4bc 100644 (file)
@@ -953,7 +953,6 @@ static void
 _widget_calculate_recursive(Eo *obj)
 {
    Elm_Widget_Smart_Data *pd = NULL;
-   Eina_List *l;
    Evas_Object *child;
 
    if (!efl_isa(obj, EFL_UI_WIDGET_CLASS)) return;
@@ -966,8 +965,11 @@ _widget_calculate_recursive(Eo *obj)
        !evas_object_smart_need_recalculate_get(pd->resize_obj))
      return;
 
-   EINA_LIST_FOREACH(pd->subobjs, l, child)
-     _widget_calculate_recursive(child);
+   for (unsigned int i = 0; i < eina_array_count(pd->children); ++i)
+     {
+        child = eina_array_data_get(pd->children, i);
+        _widget_calculate_recursive(child);
+     }
 
    evas_object_smart_calculate(obj);
 }
index 74e8f2e..7e55fd1 100644 (file)
@@ -93,7 +93,7 @@ resize_object(Efl_Canvas_Object *o)
 {
    Efl_Ui_Widget_Data *pd = efl_data_scope_safe_get(o, EFL_UI_WIDGET_CLASS);
 
-   return eina_list_data_get(pd->subobjs);
+   return eina_array_data_get(pd->children, 0);
 }
 
 EFL_START_TEST(efl_ui_test_widget_widget_sub_iterator)
@@ -182,16 +182,16 @@ EFL_START_TEST(efl_ui_test_widget_sub_object_add_del)
    State s;
 
    _small_ui(&s);
-   DISABLE_ABORT_ON_CRITICAL_START;
+   EXPECT_ERROR_START;
    ck_assert(!efl_ui_widget_sub_object_add(s.btn1, s.btn1));
-   DISABLE_ABORT_ON_CRITICAL_END;
+   EXPECT_ERROR_END;
    ck_assert(efl_ui_widget_sub_object_add(s.box, s.btn1));
-   DISABLE_ABORT_ON_CRITICAL_START;
+   EXPECT_ERROR_START;
    ck_assert(!efl_ui_widget_sub_object_add(s.box, NULL));
    ck_assert(!efl_ui_widget_sub_object_del(s.btn1, s.btn1));
    ck_assert(!efl_ui_widget_sub_object_del(s.box, NULL));
    ck_assert(!efl_ui_widget_sub_object_del(s.btn1, s.box));
-   DISABLE_ABORT_ON_CRITICAL_END;
+   EXPECT_ERROR_END;
    ck_assert(efl_ui_widget_sub_object_del(s.box, s.btn1));
 }
 EFL_END_TEST