Changeset 129e609 for functions.c


Ignore:
Timestamp:
Dec 6, 2009, 8:08:24 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
bafbba1
Parents:
2c48db8
git-author:
Nelson Elhage <nelhage@mit.edu> (12/02/09 22:09:13)
git-committer:
Nelson Elhage <nelhage@mit.edu> (12/06/09 20:08:24)
Message:
Use a owl_dict to store the list of filters.

Cathy Zhang reported that narrowing to filters that reference other
filters is significantly slower than narrowing to filters that
don't. The culprit is almost certainly the linear lookup of filters by
name, which we currently do on each filter evaluation.

Switch to using an owl_dict, which will now do a binary search over
the filter list. We could potentially get this even faster by caching
the owl_filter itself inside the owl_filterelement, and invalidating
it somehow on filter redefinition, but we can save that sort of
cleverness for later, if necessary.

We also store the filters in a linked list, in order to preserve the
ability to traverse them in order, for ":show filters" and for
coloring.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r2c48db8 r129e609  
    22492249void owl_function_show_filters(void)
    22502250{
    2251   const owl_list *l;
    22522251  const owl_filter *f;
    2253   int i, j;
     2252  GList *fl;
    22542253  owl_fmtext fm;
    22552254
    22562255  owl_fmtext_init_null(&fm);
    22572256
    2258   l=owl_global_get_filterlist(&g);
    2259   j=owl_list_get_size(l);
    2260 
    22612257  owl_fmtext_append_bold(&fm, "Filters:\n");
    22622258
    2263   for (i=0; i<j; i++) {
    2264     f=owl_list_get_element(l, i);
     2259  for (fl = g.filterlist; fl; fl = g_list_next(fl)) {
     2260    f = fl->data;
    22652261    owl_fmtext_append_normal(&fm, "   ");
    22662262    if (owl_global_get_hascolors(&g)) {
Note: See TracChangeset for help on using the changeset viewer.