edje: another O(1) lookup, but for alias of group.
authorcedric <cedric>
Tue, 11 Sep 2012 04:10:13 +0000 (04:10 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 11 Sep 2012 04:10:13 +0000 (04:10 +0000)
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

ChangeLog
NEWS
src/bin/edje_cc.h
src/bin/edje_cc_handlers.c
src/bin/edje_cc_out.c

index 746a195..5eefd0e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 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 (file)
--- 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:
 
index 4c5ec06..e7fb7a4 100644 (file)
@@ -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;
index b30f621..6e10cce 100644 (file)
@@ -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, &current_de->id, current_de);
+
    pc = mem_alloc(SZ(Edje_Part_Collection));
    edje_collections = eina_list_append(edje_collections, pc);
    pc->id = current_de->id;
index 812434d..fa68d38 100644 (file)
@@ -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);
               }
          }