From: cedric Date: Tue, 11 Sep 2012 04:10:13 +0000 (+0000) Subject: edje: another O(1) lookup, but for alias of group. X-Git-Tag: submit/2.0alpha-wayland/20121127.221958~96 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3a28ed4eaa02aa81c761a0e6163175ca365a5065;p=profile%2Fivi%2Fedje.git edje: another O(1) lookup, but for alias of group. This give a small 10% benefit on Tizen theme. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@76428 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/ChangeLog b/ChangeLog index 746a195..5eefd0e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -609,3 +609,4 @@ 2012-09-11 Cedric Bail * O(1) lookup used when searching Part_Lookup in edje_cc. + * O(1) lookup when generating alias of group. diff --git a/NEWS b/NEWS index bb46648..9a9e879 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,7 @@ Additions: Improvements: * Check the number of parameter for image in edc. * O(1) lookup used when searching Part_Lookup in edje_cc. + * O(1) lookup when generating alias of group. Fixes: diff --git a/src/bin/edje_cc.h b/src/bin/edje_cc.h index 4c5ec06..e7fb7a4 100644 --- a/src/bin/edje_cc.h +++ b/src/bin/edje_cc.h @@ -240,6 +240,7 @@ extern Eina_List *stack; extern Eina_List *params; extern Edje_File *edje_file; extern Eina_List *edje_collections; +extern Eina_Hash *edje_collections_lookup; extern Eina_List *externals; extern Eina_List *fonts; extern Eina_List *codes; diff --git a/src/bin/edje_cc_handlers.c b/src/bin/edje_cc_handlers.c index b30f621..6e10cce 100644 --- a/src/bin/edje_cc_handlers.c +++ b/src/bin/edje_cc_handlers.c @@ -1959,7 +1959,10 @@ static void ob_collections(void) { if (!edje_file->collection) - edje_file->collection = eina_hash_string_small_new(NULL); + { + edje_file->collection = eina_hash_string_small_new(NULL); + edje_collections_lookup = eina_hash_int32_new(NULL); + } } /** @@ -2219,6 +2222,8 @@ ob_collections_group(void) current_de = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry)); current_de->id = eina_list_count(edje_collections); + eina_hash_add(edje_collections_lookup, ¤t_de->id, current_de); + pc = mem_alloc(SZ(Edje_Part_Collection)); edje_collections = eina_list_append(edje_collections, pc); pc->id = current_de->id; diff --git a/src/bin/edje_cc_out.c b/src/bin/edje_cc_out.c index 812434d..fa68d38 100644 --- a/src/bin/edje_cc_out.c +++ b/src/bin/edje_cc_out.c @@ -183,6 +183,7 @@ static void data_process_string(Edje_Part_Collection *pc, const char *prefix, ch Edje_File *edje_file = NULL; Eina_List *edje_collections = NULL; +Eina_Hash *edje_collections_lookup = NULL; Eina_List *externals = NULL; Eina_List *fonts = NULL; Eina_List *codes = NULL; @@ -371,7 +372,6 @@ data_thread_head(void *data, Ecore_Thread *thread __UNUSED__) EINA_LIST_FREE(aliases, ce) { Edje_Part_Collection_Directory_Entry *sce; - Eina_Iterator *it; if (!ce->entry) { @@ -381,18 +381,12 @@ data_thread_head(void *data, Ecore_Thread *thread __UNUSED__) return; } - it = eina_hash_iterator_data_new(edje_file->collection); - - EINA_ITERATOR_FOREACH(it, sce) + sce = eina_hash_find(edje_collections_lookup, &ce->id); + if (sce) { - if (ce->id == sce->id) - { - memcpy(&ce->count, &sce->count, sizeof (ce->count)); - break; - } + memcpy(&ce->count, &sce->count, sizeof (ce->count)); } - - if (!sce) + else { snprintf(buf, sizeof(buf), "Collection %s (%i) can't find an correct alias.", @@ -400,7 +394,7 @@ data_thread_head(void *data, Ecore_Thread *thread __UNUSED__) hw->errstr = strdup(buf); return; } - eina_iterator_free(it); + eina_hash_direct_add(edje_file->collection, ce->entry, ce); } }