Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/edje

Dir     : e17/libs/edje/src/lib


Modified Files:
        edje_load.c edje_private.h edje_program.c 


Log Message:


optimizing. Glassy's matrix.eet works MUCH faster now. basically edje was not
very efficient at matching hundreds of prgorams up to lots of signals always
ticking off. i've optimized it now with a match (and no_match) cache so if an
input signal (and source) combination is known not to match anything, it's
cached after the first full check and henceforth avoids extra checks. the
cache is realyl simply right now - i could optimize it a bit to avoid excess
memory usage though...

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_load.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- edje_load.c 16 Jul 2003 05:15:15 -0000      1.11
+++ edje_load.c 20 Jul 2003 02:08:47 -0000      1.12
@@ -3,6 +3,9 @@
 
 static Evas_Hash   *_edje_file_hash = NULL;
 
+static void _edje_collection_free_part_description_free(Edje_Part_Description *desc);
+static int  _edje_collection_free_prog_cache_matches_free_cb(Evas_Hash *hash, const 
char *key, void *data, void *fdata);
+
 /* API Routines */
 void
 edje_object_file_set(Evas_Object *obj, const char *file, const char *part)
@@ -158,6 +161,15 @@
             ed->file = NULL;
             goto out;
          }
+         {
+            for (l = ed->file->collection_dir->entries; l; l = l->next)
+              {
+                 Edje_Part_Collection_Directory_Entry *ce;
+                 
+                 ce = l->data;           
+                 printf("Collection: %s\n", ce->entry);
+              }
+         }
        _edje_file_hash = evas_hash_add(_edje_file_hash, ed->path, ed->file);
      }
    
@@ -305,5 +317,75 @@
 void
 _edje_collection_free(Edje_Part_Collection *ec)
 {
-   printf("FIXME: leak Edje_Part_Collection!\n");
+   while (ec->programs)
+     {
+       Edje_Program *pr;
+       
+       pr = ec->programs->data;
+       ec->programs = evas_list_remove(ec->programs, pr);
+       if (pr->name) free(pr->name);
+       if (pr->signal) free(pr->signal);
+       if (pr->source) free(pr->source);
+       if (pr->state) free(pr->state);
+       if (pr->state2) free(pr->state2);
+       while (pr->targets)
+         {
+            Edje_Program_Target *prt;
+            
+            prt = pr->targets->data;
+            pr->targets = evas_list_remove(pr->targets, prt);
+            free(prt);
+         }
+       free(pr);
+     }
+   while (ec->parts)
+     {
+       Edje_Part *ep;
+       
+       ep = ec->parts->data;
+       ec->parts = evas_list_remove(ec->parts, ep);
+       if (ep->name) free(ep->name);
+       if (ep->color_class) free(ep->color_class);
+       if (ep->text_class) free(ep->text_class);
+       if (ep->default_desc) 
_edje_collection_free_part_description_free(ep->default_desc);
+       while (ep->other_desc)
+         {
+            Edje_Part_Description *desc;
+            
+            desc = ep->other_desc->data;
+            ep->other_desc = evas_list_remove(ep->other_desc, desc);
+            _edje_collection_free_part_description_free(desc);
+         }
+     }
+   if (ec->prog_cache.no_matches) evas_hash_free(ec->prog_cache.no_matches);
+   if (ec->prog_cache.matches)
+     {
+       evas_hash_foreach(ec->prog_cache.matches, 
_edje_collection_free_prog_cache_matches_free_cb, NULL);
+       evas_hash_free(ec->prog_cache.matches);
+     }
+   free(ec);
+}
+
+static void
+_edje_collection_free_part_description_free(Edje_Part_Description *desc)
+{
+   if (desc->state.name) free(desc->state.name);
+   while (desc->image.tween_list)
+     {
+       Edje_Part_Image_Id *pi;
+       
+       pi = desc->image.tween_list->data;
+       desc->image.tween_list = evas_list_remove(desc->image.tween_list, pi);
+       free(pi);
+     }
+   if (desc->text.text) free(desc->text.text);
+   if (desc->text.font) free(desc->text.font);
+   free(desc);
+}
+
+static int
+_edje_collection_free_prog_cache_matches_free_cb(Evas_Hash *hash, const char *key, 
void *data, void *fdata)
+{
+   evas_list_free((Evas_List *)data);
+   return 1;
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_private.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -3 -r1.32 -r1.33
--- edje_private.h      16 Jul 2003 13:50:28 -0000      1.32
+++ edje_private.h      20 Jul 2003 02:08:47 -0000      1.33
@@ -183,6 +183,10 @@
    int        id; /* the collection id */
    
    int        references;
+   struct {
+      Evas_Hash                   *no_matches;
+      Evas_Hash                   *matches;
+   } prog_cache;
 };
 
 struct _Edje_Part
@@ -343,6 +347,7 @@
    Evas_List            *text_classes;
    int                   freeze;
    int                   references;
+   
 };
 
 struct _Edje_Real_Part
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_program.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- edje_program.c      8 Jul 2003 10:08:15 -0000       1.7
+++ edje_program.c      20 Jul 2003 02:08:47 -0000      1.8
@@ -442,7 +442,7 @@
    recursions++;
    _edje_ref(ed);
    _edje_freeze(ed);
-   printf("EMIT \"%s\" \"%s\"\n", sig, src);
+//   printf("EMIT \"%s\" \"%s\"\n", sig, src);
    ee = calloc(1, sizeof(Edje_Emission));
    if (!ee)
      {
@@ -469,17 +469,73 @@
        emissions = evas_list_remove(emissions, ee);
        if (ed->collection)
          {
-            for (l = ed->collection->programs; l; l = l->next)
+            Edje_Part_Collection *ec;
+            char *tmps;
+            int l1, l2;
+            int done;
+            
+            ec = ed->collection;
+            l1 = strlen(ee->signal);
+            l2 = strlen(ee->source);
+            tmps = malloc(l1 + l2 + 2);
+            
+            if (tmps)
               {
-                 Edje_Program *pr;
+                 strcpy(tmps, ee->signal);
+                 tmps[l1] = '\377';
+                 strcpy(&(tmps[l1 + 1]), ee->source);
+              }
+            done = 0;
+            
+            if (tmps)
+              {
+                 Evas_List *matches;
+                 
+                 if (evas_hash_find(ec->prog_cache.no_matches, tmps))
+                   done = 1;
+                 else if ((matches = evas_hash_find(ec->prog_cache.matches, tmps)))
+                   {
+                      for (l = matches; l; l = l->next)
+                        {
+                           Edje_Program *pr;
+                           
+                           pr = l->data;
+                           _edje_program_run(ed, pr, 0);
+                        }
+                      done = 1;
+                   }
+              }
+            if (!done)
+              {
+                 int matched = 0;
+                 Evas_List *matches = NULL;
                  
-                 pr = l->data;
-                 if ((pr->signal) &&
-                     (pr->source) &&
-                     (_edje_glob_match(ee->signal, pr->signal)) &&
-                     (_edje_glob_match(ee->source, pr->source)))
-                   _edje_program_run(ed, pr, 0);
+                 for (l = ed->collection->programs; l; l = l->next)
+                   {
+                      Edje_Program *pr;
+                      
+                      pr = l->data;
+                      if ((pr->signal) &&
+                          (pr->source) &&
+                          (_edje_glob_match(ee->signal, pr->signal)) &&
+                          (_edje_glob_match(ee->source, pr->source)))
+                        {
+                           matched++;
+                           _edje_program_run(ed, pr, 0);
+                           matches = evas_list_append(matches, pr);
+                        }
+                   }
+                 if (tmps)
+                   {
+                      if (matched == 0)
+                        ec->prog_cache.no_matches = 
+                        evas_hash_add(ec->prog_cache.no_matches, tmps, ed);
+                      else
+                        ec->prog_cache.matches =
+                        evas_hash_add(ec->prog_cache.matches, tmps, matches);
+                   }
               }
+            if (tmps) free(tmps);
             ed->walking_callbacks = 1;
             for (l = ed->callbacks; l; l = l->next)
               {




-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to