Changeset 3f6555d


Ignore:
Timestamp:
May 16, 2010, 1:15:25 AM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
c314f39
Parents:
f034ac0
git-author:
David Benjamin <davidben@mit.edu> (05/15/10 17:38:31)
git-committer:
David Benjamin <davidben@mit.edu> (05/16/10 01:15:25)
Message:
Punt obarray and friends in favor of g_intern_string

It's somewhat faster (about 1.5x by completely unrigorous tests), and
it's less code for us to maintain.

Signed-off-by: David Benjamin <davidben@mit.edu>
Files:
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • Makefile.am

    rae333f0 r3f6555d  
    4848     keypress.c keymap.c keybinding.c cmd.c context.c \
    4949     aim.c buddy.c buddylist.c style.c errqueue.c \
    50      zbuddylist.c popexec.c obarray.c select.c wcwidth.c \
     50     zbuddylist.c popexec.c select.c wcwidth.c \
    5151     glib_compat.c filterproc.c
    5252
  • global.c

    r0881cdd r3f6555d  
    113113  g->pseudologin_notify = 0;
    114114
    115   owl_obarray_init(&(g->obarray));
    116 
    117115  owl_message_init_fmtext_cache();
    118116  owl_list_create(&(g->io_dispatch_list));
     
    10121010}
    10131011
    1014 const char * owl_global_intern(owl_global *g, const char * string)
    1015 {
    1016   return owl_obarray_insert(&(g->obarray), string);
    1017 }
    1018 
    10191012owl_list *owl_global_get_io_dispatch_list(owl_global *g)
    10201013{
  • message.c

    r9a7b4f2 r3f6555d  
    7474  if(pair ==  NULL) {
    7575    pair = owl_malloc(sizeof(owl_pair));
    76     owl_pair_create(pair, owl_global_intern(&g, attrname), NULL);
     76    owl_pair_create(pair, g_intern_string(attrname), NULL);
    7777    owl_list_append_element(&(m->attributes), pair);
    7878  }
     
    496496void owl_message_set_hostname(owl_message *m, const char *hostname)
    497497{
    498   m->hostname=owl_global_intern(&g, hostname);
     498  m->hostname = g_intern_string(hostname);
    499499}
    500500
  • owl.h

    r7ba9e0de r3f6555d  
    521521  short **pairs;
    522522} owl_colorpair_mgr;
    523 
    524 typedef struct _owl_obarray {
    525   owl_list strings;
    526 } owl_obarray;
    527523
    528524typedef struct _owl_io_dispatch {
     
    623619  int pseudologin_notify;
    624620  struct termios startup_tio;
    625   owl_obarray obarray;
    626621  owl_list io_dispatch_list;
    627622  owl_list psa_list;
  • tester.c

    rf034ac0 r3f6555d  
    3333  numfailures += owl_variable_regtest();
    3434  numfailures += owl_filter_regtest();
    35   numfailures += owl_obarray_regtest();
    3635  numfailures += owl_editwin_regtest();
    3736  if (numfailures) {
     
    301300}
    302301
    303 
    304 int owl_obarray_regtest(void) {
    305   int numfailed = 0;
    306   const char *p,*p2;
    307 
    308   owl_obarray oa;
    309   owl_obarray_init(&oa);
    310 
    311   printf("# BEGIN testing owl_obarray\n");
    312 
    313   p = owl_obarray_insert(&oa, "test");
    314   FAIL_UNLESS("returned string is equal", p && !strcmp(p, "test"));
    315   p2 = owl_obarray_insert(&oa, "test");
    316   FAIL_UNLESS("returned string is equal", p2 && !strcmp(p2, "test"));
    317   FAIL_UNLESS("returned the same string", p2 && p == p2);
    318 
    319   p = owl_obarray_insert(&oa, "test2");
    320   FAIL_UNLESS("returned string is equal", p && !strcmp(p, "test2"));
    321   p2 = owl_obarray_find(&oa, "test2");
    322   FAIL_UNLESS("returned the same string", p2 && !strcmp(p2, "test2"));
    323 
    324   p = owl_obarray_find(&oa, "nothere");
    325   FAIL_UNLESS("Didn't find a string that isn't there", p == NULL);
    326 
    327   printf("# END testing owl_obarray (%d failures)\n", numfailed);
    328 
    329   return numfailed;
    330 }
    331 
    332302int owl_editwin_regtest(void) {
    333303  int numfailed = 0;
Note: See TracChangeset for help on using the changeset viewer.