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...


SVN revision: 7189
This commit is contained in:
Carsten Haitzler 2003-07-20 02:08:47 +00:00
parent 368cac9350
commit f212675a33
5 changed files with 159 additions and 14 deletions

View File

@ -21,7 +21,7 @@ edje_LDADD = \
$(top_builddir)/src/lib/libedje.la \
@imlib2_libs@
edje_LDFLAGS =
edje_LDFLAGS = -static
edje_DEPENDENCIES = $(top_builddir)/src/lib/libedje.la

View File

@ -331,8 +331,10 @@ bottom_move_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
y -= 20;
w += 20;
h += 30;
minw = 20 + de->minw;
minh = 30 + de->minh;
// minw = 20 + de->minw;
// minh = 30 + de->minh;
minw = 20;
minh = 30;
if (hdir > 0)
{
w += ev->cur.canvas.x - ev->prev.canvas.x;

View File

@ -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 @@ _edje_file_add(Edje *ed)
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 @@ _edje_file_free(Edje_File *edf)
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;
}

View File

@ -183,6 +183,10 @@ struct _Edje_Part_Collection
int id; /* the collection id */
int references;
struct {
Evas_Hash *no_matches;
Evas_Hash *matches;
} prog_cache;
};
struct _Edje_Part
@ -343,6 +347,7 @@ struct _Edje
Evas_List *text_classes;
int freeze;
int references;
};
struct _Edje_Real_Part

View File

@ -442,7 +442,7 @@ _edje_emit(Edje *ed, char *sig, char *src)
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 @@ _edje_emit(Edje *ed, char *sig, char *src)
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;
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);
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;
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)
{