if we aren't looking for a glob... why do we go alloc a possible
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 6 Dec 2010 07:49:00 +0000 (07:49 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 6 Dec 2010 07:49:00 +0000 (07:49 +0000)
massive pattern match thing.. if you have a LOOOOOOOOOOT of collection
entries... that can be a big set.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@55316 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/edje_load.c

index f20951d..829f20b 100644 (file)
@@ -181,6 +181,8 @@ edje_file_group_exists(const char *file, const char *glob)
    Edje_File *edf;
    int error_ret = 0;
    Eina_Bool succeed = EINA_FALSE;
+   Eina_Bool is_glob = EINA_FALSE;
+   const char *p;
 
    if ((!file) || (!*file))
       return EINA_FALSE;
@@ -188,25 +190,46 @@ edje_file_group_exists(const char *file, const char *glob)
    edf = _edje_cache_file_coll_open(file, NULL, &error_ret, NULL);
    if (!edf)
       return EINA_FALSE;
-
-   if (!edf->collection_patterns)
+   
+   for (p = glob; *p; p++)
      {
-        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_free(i);
-
-        edf->collection_patterns = edje_match_collection_dir_init(l);
-        eina_list_free(l);
+       if ((*p == '*') || (*p == '?') || (*p == '['))
+         {
+           is_glob = EINA_TRUE;
+           break;
+         }
+     }
+  
+   if (is_glob)
+     {
+       if (!edf->collection_patterns)
+         {
+           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_free(i);
+           
+           edf->collection_patterns = edje_match_collection_dir_init(l);
+           eina_list_free(l);
+         }
+       
+       succeed = edje_match_collection_dir_exec(edf->collection_patterns, glob);
+       if (edf->collection_patterns)
+         {
+           edje_match_patterns_free(edf->collection_patterns);
+           edf->collection_patterns = NULL;
+         }
+     }
+   else
+     {
+        if (eina_hash_find(edf->collection, glob)) succeed = EINA_TRUE;
      }
-
-   succeed = edje_match_collection_dir_exec(edf->collection_patterns, glob);
    _edje_cache_file_unref(edf);
    return succeed;
 }