* Dramatically improved the time it takes to goto (or select) a room which
authorArt Cancro <ajc@citadel.org>
Fri, 20 May 2005 16:14:44 +0000 (16:14 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 20 May 2005 16:14:44 +0000 (16:14 +0000)
  contains a very long and complex seen/unseen list.  Our test folder,
  containing 359 new of 3162 messages, formerly took 22 seconds to select;
  now it takes 1 to 2 seconds.

citadel/ChangeLog
citadel/room_ops.c
citadel/tools.c

index 4d13a37e4de641e95e6e6b2f55a871d9b3629d06..13d0567d2978281fdafe84caf4c8f6c0e0acc1d6 100644 (file)
@@ -1,4 +1,10 @@
  $Log$
+ Revision 647.15  2005/05/20 16:14:43  ajc
+ * Dramatically improved the time it takes to goto (or select) a room which
+   contains a very long and complex seen/unseen list.  Our test folder,
+   containing 359 new of 3162 messages, formerly took 22 seconds to select;
+   now it takes 1 to 2 seconds.
+
  Revision 647.14  2005/05/20 02:37:17  ajc
  * Performance-optimized the full text indexer.
 
@@ -6739,3 +6745,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index f383686064f2d4cd98140db4f3621de56e66bc08..cb73a80cd53251e883910e8554ce09803fe56a19 100644 (file)
@@ -766,6 +766,7 @@ void usergoto(char *where, int display_result, int transiently,
 {
        int a;
        int new_messages = 0;
+       int old_messages = 0;
        int total_messages = 0;
        int info = 0;
        int rmailflag;
@@ -777,6 +778,10 @@ void usergoto(char *where, int display_result, int transiently,
        long *msglist = NULL;
        int num_msgs = 0;
        unsigned int original_v_flags;
+       int num_sets;
+       int s;
+       char setstr[128], lostr[64], histr[64];
+       long lo, hi;
 
        /* If the supplied room name is NULL, the caller wants us to know that
         * it has already copied the room record into CC->room, so
@@ -825,14 +830,38 @@ void usergoto(char *where, int display_result, int transiently,
                cdb_free(cdbfr);
        }
 
-       if (num_msgs > 0) for (a = 0; a < num_msgs; ++a) {
-               if (msglist[a] > 0L) {
-                       ++total_messages;
-                       if (is_msg_in_sequence_set(vbuf.v_seen, msglist[a]) == 0) {
-                               ++new_messages;
+       lprintf(CTDL_DEBUG, " *** START COUNT *** \n");
+       total_messages = 0;
+       for (a=0; a<num_msgs; ++a) {
+               if (msglist[a] > 0L) ++total_messages;
+       }
+       new_messages = num_msgs;
+       num_sets = num_tokens(vbuf.v_seen, ',');
+       for (s=0; s<num_sets; ++s) {
+               extract_token(setstr, vbuf.v_seen, s, ',', sizeof setstr);
+
+               extract_token(lostr, setstr, 0, ':', sizeof lostr);
+               if (num_tokens(setstr, ':') >= 2) {
+                       extract_token(histr, setstr, 1, ':', sizeof histr);
+                       if (!strcmp(histr, "*")) {
+                               snprintf(histr, sizeof histr, "%ld", LONG_MAX);
+                       }
+               } 
+               else {
+                       strcpy(histr, lostr);
+               }
+               lo = atol(lostr);
+               hi = atol(histr);
+
+               for (a=0; a<num_msgs; ++a) if (msglist[a] > 0L) {
+                       if ((msglist[a] >= lo) && (msglist[a] <= hi)) {
+                               ++old_messages;
+                               msglist[a] = 0L;
                        }
                }
        }
+       lprintf(CTDL_DEBUG, " ***  END  COUNT *** \n");
+       new_messages = total_messages - old_messages;
 
        if (msglist != NULL) free(msglist);
 
index abdf2bc8d5fd62fa1f75deb1192d86d859bed93f..3a6117435c44f29393dac719eefe30b2ffb7e8b2 100644 (file)
@@ -414,7 +414,7 @@ void fmt_date(char *buf, size_t n, time_t thetime, int seconds) {
 int is_msg_in_sequence_set(char *mset, long msgnum) {
        int num_sets;
        int s;
-       char setstr[SIZ], lostr[SIZ], histr[SIZ];
+       char setstr[128], lostr[128], histr[128];
        long lo, hi;
 
        num_sets = num_tokens(mset, ',');