* edje: add an cache for group exist test.
authorcedric <cedric>
Mon, 28 Jun 2010 17:18:47 +0000 (17:18 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 28 Jun 2010 17:18:47 +0000 (17:18 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@49928 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/edje_convert.c
src/lib/edje_load.c
src/lib/edje_private.h

index 7519afb..8a44489 100644 (file)
@@ -127,7 +127,10 @@ _edje_file_convert(Eet_File *file, Old_Edje_File *oedf)
    edf->dangling = EINA_FALSE;
    edf->warning = EINA_FALSE;
 
+   /* Below you will find all memory structure that could be cleaned when under
+      memory pressure */
    edf->collection_cache = NULL;
+   edf->collection_patterns = NULL;
 
    return edf;
 }
index 096f109..bb7ed86 100644 (file)
@@ -192,25 +192,32 @@ edje_file_group_exists(const char *file, const char *glob)
    edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
    if (edf != NULL)
      {
-       /* FIXME: cache the result in Edje_File structure */
-       Edje_Part_Collection_Directory_Entry *ce;
-       Eina_Iterator *i;
-       Eina_List *l = NULL;
        Edje_Patterns *patterns;
 
-       i = eina_hash_iterator_data_new(edf->collection);
+       if (edf->collection_patterns)
+         {
+            patterns = edf->collection_patterns;
+         }
+       else
+         {
+            Edje_Part_Collection_Directory_Entry *ce;
+            Eina_Iterator *i;
+            Eina_List *l = NULL;
+
+            i = eina_hash_iterator_data_new(edf->collection);
 
-       EINA_ITERATOR_FOREACH(i, ce)
-         l = eina_list_append(l, ce);
+            EINA_ITERATOR_FOREACH(i, ce)
+              l = eina_list_append(l, ce);
 
-       eina_iterator_free(i);
+            eina_iterator_free(i);
 
-       patterns = edje_match_collection_dir_init(l);
+            patterns = edje_match_collection_dir_init(l);
+            eina_list_free(l);
+         }
 
        succeed = edje_match_collection_dir_exec(patterns, glob);
 
-       edje_match_patterns_free(patterns);
-       eina_list_free(l);
+       edf->collection_patterns = patterns;
 
        _edje_cache_file_unref(edf);
      }
@@ -1065,6 +1072,7 @@ _edje_file_free(Edje_File *edf)
        free(ecc);
      }
 
+   if (edf->collection_patterns) edje_match_patterns_free(edf->collection_patterns);
    if (edf->path) eina_stringshare_del(edf->path);
    if (edf->free_strings && edf->compiler) eina_stringshare_del(edf->compiler);
    if (edf->collection_cache) _edje_cache_coll_flush(edf);
index a9d936c..05fda4b 100644 (file)
@@ -337,6 +337,8 @@ struct _Edje_File
    Eina_Hash                     *collection;
    Eina_List                     *collection_cache;
 
+   Edje_Patterns                 *collection_patterns;
+
    Eet_File                       *ef;
 
    Old_Edje_File                 *oef;