edje: reduce memory used per callback.

SVN revision: 76517
This commit is contained in:
Cedric BAIL 2012-09-12 11:16:57 +00:00
parent e683bab25e
commit 4791a710f2
5 changed files with 40 additions and 27 deletions

View File

@ -615,6 +615,11 @@
2012-09-11 Carsten Haitzler (The Rasterman) 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 struct down by less than half its size and making some parts allocated
extra only if the type needs it. 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.

View File

@ -16,6 +16,7 @@ Improvements:
* O(1) lookup when generating alias of group. * O(1) lookup when generating alias of group.
* O(1) access time for parameters in edje_cc_handler. * O(1) access time for parameters in edje_cc_handler.
* Recycle and use less memory during load time. * Recycle and use less memory during load time.
* Less memory used per callbacks.
Fixes: Fixes:

View File

@ -750,13 +750,13 @@ edje_match_program_hash_build(Edje_Program * const *programs,
item->signal = programs[i]->signal; item->signal = programs[i]->signal;
item->source = programs[i]->source; 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), new = eina_rbtree_inline_insert(new, EINA_RBTREE_GET(item),
EINA_RBTREE_CMP_NODE_CB(_edje_signal_source_node_cmp), NULL); 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 else
result = eina_list_prepend(result, programs[i]); result = eina_list_prepend(result, programs[i]);
@ -791,13 +791,13 @@ edje_match_callback_hash_build(const Eina_List *callbacks,
item->signal = callback->signal; item->signal = callback->signal;
item->source = callback->source; 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), new = eina_rbtree_inline_insert(new, EINA_RBTREE_GET(item),
EINA_RBTREE_CMP_NODE_CB(_edje_signal_source_node_cmp), NULL); 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 else
result = eina_list_prepend(result, callback); result = eina_list_prepend(result, callback);
@ -807,7 +807,7 @@ edje_match_callback_hash_build(const Eina_List *callbacks,
return result; return result;
} }
const Eina_List * const Eina_Array *
edje_match_signal_source_hash_get(const char *sig, edje_match_signal_source_hash_get(const char *sig,
const char *source, const char *source,
const Eina_Rbtree *tree) const Eina_Rbtree *tree)
@ -817,13 +817,13 @@ edje_match_signal_source_hash_get(const char *sig,
lookup = (Edje_Signal_Source_Char*) eina_rbtree_inline_lookup(tree, sig, 0, lookup = (Edje_Signal_Source_Char*) eina_rbtree_inline_lookup(tree, sig, 0,
EINA_RBTREE_CMP_KEY_CB(_edje_signal_source_key_cmp), source); EINA_RBTREE_CMP_KEY_CB(_edje_signal_source_key_cmp), source);
if (lookup) return lookup->list; if (lookup) return &lookup->list;
return NULL; return NULL;
} }
void void
edje_match_signal_source_free(Edje_Signal_Source_Char *key, __UNUSED__ void *data) 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); free(key);
} }

View File

@ -1083,7 +1083,7 @@ struct _Edje_Signal_Source_Char
const char *signal; const char *signal;
const char *source; const char *source;
Eina_List *list; Eina_Array list;
}; };
struct _Edje_Signals_Sources_Patterns struct _Edje_Signals_Sources_Patterns
@ -1672,9 +1672,9 @@ Eina_List *edje_match_program_hash_build(Edje_Program * const * programs,
Eina_Rbtree **tree); Eina_Rbtree **tree);
Eina_List *edje_match_callback_hash_build(const Eina_List *callbacks, Eina_List *edje_match_callback_hash_build(const Eina_List *callbacks,
Eina_Rbtree **tree); Eina_Rbtree **tree);
const Eina_List *edje_match_signal_source_hash_get(const char *signal, const Eina_Array *edje_match_signal_source_hash_get(const char *signal,
const char *source, const char *source,
const Eina_Rbtree *tree); const Eina_Rbtree *tree);
void edje_match_signal_source_free(Edje_Signal_Source_Char *key, void *data); void edje_match_signal_source_free(Edje_Signal_Source_Char *key, void *data);
// FIXME remove below 2 eapi decls when edje_convert goes // FIXME remove below 2 eapi decls when edje_convert goes

View File

@ -1211,9 +1211,13 @@ _edje_emit_handle(Edje *ed, const char *sig, const char *src,
if (ed->table_programs_size > 0) if (ed->table_programs_size > 0)
{ {
const Eina_List *match; const Eina_Array *match;
#ifdef EDJE_PROGRAM_CACHE
const Eina_List *l; const Eina_List *l;
#endif
Edje_Program *pr; Edje_Program *pr;
Eina_Array_Iterator iterator;
unsigned int i;
if (ed->patterns.programs.u.programs.globing) if (ed->patterns.programs.u.programs.globing)
if (edje_match_programs_exec(ed->patterns.programs.signals_patterns, if (edje_match_programs_exec(ed->patterns.programs.signals_patterns,
@ -1228,8 +1232,9 @@ _edje_emit_handle(Edje *ed, const char *sig, const char *src,
match = edje_match_signal_source_hash_get(sig, src, match = edje_match_signal_source_hash_get(sig, src,
ed->patterns.programs.exact_match); ed->patterns.programs.exact_match);
EINA_LIST_FOREACH(match, l, pr) if (match)
_edje_glob_callback(pr, &data); EINA_ARRAY_ITER_NEXT(match, i, pr, iterator)
_edje_glob_callback(pr, &data);
#ifdef EDJE_PROGRAM_CACHE #ifdef EDJE_PROGRAM_CACHE
EINA_LIST_FOREACH(data.matches, l, pr) EINA_LIST_FOREACH(data.matches, l, pr)
@ -1307,8 +1312,9 @@ _edje_emit_cb(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Da
if (ed->callbacks) if (ed->callbacks)
{ {
Edje_Signal_Callback *escb; Edje_Signal_Callback *escb;
const Eina_List *match; const Eina_Array *match;
const Eina_List *l2; Eina_Array_Iterator iterator;
unsigned int i;
int r = 1; int r = 1;
callback_extra_data = (data) ? data->data : NULL; callback_extra_data = (data) ? data->data : NULL;
@ -1327,16 +1333,17 @@ _edje_emit_cb(Edje *ed, const char *sig, const char *src, Edje_Message_Signal_Da
match = edje_match_signal_source_hash_get(sig, src, match = edje_match_signal_source_hash_get(sig, src,
ed->patterns.callbacks.exact_match); ed->patterns.callbacks.exact_match);
EINA_LIST_FOREACH(match, l2, escb) if (match)
{ EINA_ARRAY_ITER_NEXT(match, i, escb, iterator)
if ((prop) && (escb->propagate)) continue; {
if ((!escb->just_added) && (!escb->delete_me)) 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)) escb->func(escb->data, ed->obj, sig, src);
break; if (_edje_block_break(ed))
} break;
} }
}
} }
break_prog: break_prog: