Changeset 20aced3


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:
2cfc6d7
Parents:
c314f39
git-author:
David Benjamin <davidben@mit.edu> (05/14/10 20:22:01)
git-committer:
David Benjamin <davidben@mit.edu> (05/16/10 01:15:25)
Message:
Use GQueue instead of owl_list for the incoming message queue

Otherwise, we process the queue in O(N^2) time. This isn't actually a
bottleneck, but it becomes one whenever we create fake messages in bulk
for testing purposes.

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

Legend:

Unmodified
Added
Removed
  • global.c

    r3f6555d r20aced3  
    5353  g->filterlist = NULL;
    5454  owl_list_create(&(g->puntlist));
    55   owl_list_create(&(g->messagequeue));
     55  g->messagequeue = g_queue_new();
    5656  owl_dict_create(&(g->styledict));
    5757  g->curmsg_vert_offset=0;
     
    862862void owl_global_messagequeue_addmsg(owl_global *g, owl_message *m)
    863863{
    864   owl_list_append_element(&(g->messagequeue), m);
     864  g_queue_push_tail(g->messagequeue, m);
    865865}
    866866
     
    873873  owl_message *out;
    874874
    875   if (owl_list_get_size(&(g->messagequeue))==0) return(NULL);
    876   out=owl_list_get_element(&(g->messagequeue), 0);
    877   owl_list_remove_element(&(g->messagequeue), 0);
    878   return(out);
     875  if (g_queue_is_empty(g->messagequeue))
     876    return NULL;
     877  out = g_queue_pop_head(g->messagequeue);
     878  return out;
    879879}
    880880
    881881int owl_global_messagequeue_pending(owl_global *g)
    882882{
    883   if (owl_list_get_size(&(g->messagequeue))==0) return(0);
    884   return(1);
     883  return !g_queue_is_empty(g->messagequeue);
    885884}
    886885
  • owl.h

    r3f6555d r20aced3  
    606606  char *aim_screenname_for_filters;     /* currently logged in AIM screen name */
    607607  owl_buddylist buddylist;  /* list of logged in AIM buddies */
    608   owl_list messagequeue;    /* for queueing up aim and other messages */
     608  GQueue *messagequeue;     /* for queueing up aim and other messages */
    609609  owl_dict styledict;       /* global dictionary of available styles */
    610610  char *response;           /* response to the last question asked */
Note: See TracChangeset for help on using the changeset viewer.