Consider using "inarray", may be doable here.

On Wednesday, September 12, 2012, Enlightenment SVN wrote:

> Log:
> edje: reduce memory used per callback.
>
>
> Author:       cedric
> Date:         2012-09-12 04:16:57 -0700 (Wed, 12 Sep 2012)
> New Revision: 76517
> Trac:         http://trac.enlightenment.org/e/changeset/76517
>
> Modified:
>   trunk/edje/ChangeLog trunk/edje/NEWS trunk/edje/src/lib/edje_match.c
> trunk/edje/src/lib/edje_private.h trunk/edje/src/lib/edje_program.c
>
> Modified: trunk/edje/ChangeLog
> ===================================================================
> --- trunk/edje/ChangeLog        2012-09-12 10:37:29 UTC (rev 76516)
> +++ trunk/edje/ChangeLog        2012-09-12 11:16:57 UTC (rev 76517)
> @@ -615,6 +615,11 @@
>
>  2012-09-11  Carsten Haitzler (The Rasterman)
>
> -        * Improve memory footrpint by cutting core edje real part
> +        * Improve memory footprint by cutting core edje real part
>          struct down by less than half its size and making some parts
> allocated
>          extra only if the type needs it.
> +
> +2012-09-12  Cedric Bail
> +
> +       * Small improvement in memory footprint by using an array instead
> of a list for
> +       some callback list.
>
> Modified: trunk/edje/NEWS
> ===================================================================
> --- trunk/edje/NEWS     2012-09-12 10:37:29 UTC (rev 76516)
> +++ trunk/edje/NEWS     2012-09-12 11:16:57 UTC (rev 76517)
> @@ -16,6 +16,7 @@
>      * O(1) lookup when generating alias of group.
>      * O(1) access time for parameters in edje_cc_handler.
>      * Recycle and use less memory during load time.
> +    * Less memory used per callbacks.
>
>  Fixes:
>
>
> Modified: trunk/edje/src/lib/edje_match.c
> ===================================================================
> --- trunk/edje/src/lib/edje_match.c     2012-09-12 10:37:29 UTC (rev 76516)
> +++ trunk/edje/src/lib/edje_match.c     2012-09-12 11:16:57 UTC (rev 76517)
> @@ -750,13 +750,13 @@
>
>                   item->signal = programs[i]->signal;
>                   item->source = programs[i]->source;
> -                 item->list = NULL;
> +                 eina_array_step_set(&item->list, sizeof (Eina_Array), 8);
>
>                   new = eina_rbtree_inline_insert(new,
> EINA_RBTREE_GET(item),
>
> EINA_RBTREE_CMP_NODE_CB(_edje_signal_source_node_cmp), NULL);
>                }
>
> -            item->list = eina_list_prepend(item->list, programs[i]);
> +            eina_array_push(&item->list, programs[i]);
>           }
>         else
>             result = eina_list_prepend(result, programs[i]);
> @@ -791,13 +791,13 @@
>
>                   item->signal = callback->signal;
>                   item->source = callback->source;
> -                 item->list = NULL;
> +                 eina_array_step_set(&item->list, sizeof (Eina_Array), 8);
>
>                   new = eina_rbtree_inline_insert(new,
> EINA_RBTREE_GET(item),
>
> EINA_RBTREE_CMP_NODE_CB(_edje_signal_source_node_cmp), NULL);
>                }
>
> -            item->list = eina_list_prepend(item->list, callback);
> +            eina_array_push(&item->list, callback);
>           }
>         else
>             result = eina_list_prepend(result, callback);
> @@ -807,7 +807,7 @@
>     return result;
>  }
>
> -const Eina_List *
> +const Eina_Array *
>  edje_match_signal_source_hash_get(const char *sig,
>                                   const char *source,
>                                   const Eina_Rbtree *tree)
> @@ -817,13 +817,13 @@
>     lookup = (Edje_Signal_Source_Char*) eina_rbtree_inline_lookup(tree,
> sig, 0,
>
>  EINA_RBTREE_CMP_KEY_CB(_edje_signal_source_key_cmp), source);
>
> -   if (lookup) return lookup->list;
> +   if (lookup) return &lookup->list;
>     return NULL;
>  }
>
>  void
>  edje_match_signal_source_free(Edje_Signal_Source_Char *key, __UNUSED__
> void *data)
>  {
> -   eina_list_free(key->list);
> +   eina_array_flush(&key->list);
>     free(key);
>  }
>
> Modified: trunk/edje/src/lib/edje_private.h
> ===================================================================
> --- trunk/edje/src/lib/edje_private.h   2012-09-12 10:37:29 UTC (rev 76516)
> +++ trunk/edje/src/lib/edje_private.h   2012-09-12 11:16:57 UTC (rev 76517)
> @@ -1083,7 +1083,7 @@
>     const char *signal;
>     const char *source;
>
> -   Eina_List *list;
> +   Eina_Array  list;
>  };
>
>  struct _Edje_Signals_Sources_Patterns
> @@ -1672,9 +1672,9 @@
>                                          Eina_Rbtree **tree);
>  Eina_List *edje_match_callback_hash_build(const Eina_List *callbacks,
>                                           Eina_Rbtree **tree);
> -const Eina_List *edje_match_signal_source_hash_get(const char *signal,
> -                                                  const char *source,
> -                                                  const Eina_Rbtree
> *tree);
> +const Eina_Array *edje_match_signal_source_hash_get(const char *signal,
> +                                                   const char *source,
> +                                                   const Eina_Rbtree
> *tree);
>  void edje_match_signal_source_free(Edje_Signal_Source_Char *key, void
> *data);
>
>  // FIXME remove below 2 eapi decls when edje_convert goes
>
> Modified: trunk/edje/src/lib/edje_program.c
> ===================================================================
> --- trunk/edje/src/lib/edje_program.c   2012-09-12 10:37:29 UTC (rev 76516)
> +++ trunk/edje/src/lib/edje_program.c   2012-09-12 11:16:57 UTC (rev 76517)
> @@ -1211,9 +1211,13 @@
>
>               if (ed->table_programs_size > 0)
>                 {
> -                 const Eina_List *match;
> +                 const Eina_Array *match;
> +#ifdef EDJE_PROGRAM_CACHE
>                   const Eina_List *l;
> +#endif
>                   Edje_Program *pr;
> +                 Eina_Array_Iterator iterator;
> +                 unsigned int i;
>
>                   if (ed->patterns.programs.u.programs.globing)
>                     if
> (edje_match_programs_exec(ed->patterns.programs.signals_patterns,
> @@ -1228,8 +1232,9 @@
>
>                   match = edje_match_signal_source_hash_get(sig, src,
>
> ed->patterns.programs.exact_match);
> -                 EINA_LIST_FOREACH(match, l, pr)
> -                   _edje_glob_callback(pr, &data);
> +                  if (match)
> +                    EINA_ARRAY_ITER_NEXT(match, i, pr, iterator)
> +                      _edje_glob_callback(pr, &data);
>
>  #ifdef EDJE_PROGRAM_CACHE
>                    EINA_LIST_FOREACH(data.matches, l, pr)
> @@ -1307,8 +1312,9 @@
>     if (ed->callbacks)
>       {
>         Edje_Signal_Callback *escb;
> -       const Eina_List *match;
> -       const Eina_List *l2;
> +       const Eina_Array *match;
> +        Eina_Array_Iterator iterator;
> +        unsigned int i;
>          int r = 1;
>          callback_extra_data = (data) ? data->data : NULL;
>
> @@ -1327,16 +1333,17 @@
>
>         match = edje_match_signal_source_hash_get(sig, src,
>
> ed->patterns.callbacks.exact_match);
> -       EINA_LIST_FOREACH(match, l2, escb)
> -          {
> -             if ((prop) && (escb->propagate)) continue;
> -             if ((!escb->just_added) && (!escb->delete_me))
> -               {
> -                  escb->func(escb->data, ed->obj, sig, src);
> -                  if (_edje_block_break(ed))
> -                    break;
> -               }
> -          }
> +        if (match)
> +          EINA_ARRAY_ITER_NEXT(match, i, escb, iterator)
> +            {
> +               if ((prop) && (escb->propagate)) continue;
> +               if ((!escb->just_added) && (!escb->delete_me))
> +                 {
> +                    escb->func(escb->data, ed->obj, sig, src);
> +                    if (_edje_block_break(ed))
> +                      break;
> +                 }
> +            }
>       }
>     break_prog:
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> enlightenment-svn mailing list
> enlightenment-...@lists.sourceforge.net <javascript:;>
> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
>


-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbi...@gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to