#include "citserver.h"
#include "support.h"
#include "config.h"
-#include "serv_extensions.h"
#include "room_ops.h"
#include "user_ops.h"
#include "policy.h"
int i;
char roomname[ROOMNAMELEN];
struct ctdlroom qrbuf;
- struct timeval tv1, tv2, tv3;
+ long *selected_msgs = NULL;
int num_selected = 0;
if (IMAP->num_msgs < 1) {
if (i != 0) return(i);
/*
- * Optimization note ... ajc 2005oct09
- *
- * As we can see below, we're going to end up making lots of
- * repeated calls to CtdlCopyMsgToRoom() if the user selects
- * multiple messages and then does a copy or move operation.
- *
- * The plan (documented in this comment so I don't forget what I was
- * going to do) is to refactor CtdlCopyMsgToRoom() so that it accepts
- * a list of message ID's instead of a single one. Then we can alter
- * the code which appears below, to copy all the message pointers in
- * one shot.
- *
+ * Copy all the message pointers in one shot.
*/
- gettimeofday(&tv1, NULL);
+ selected_msgs = malloc(sizeof(long) * IMAP->num_msgs);
+ if (selected_msgs == NULL) return(-1);
+
for (i = 0; i < IMAP->num_msgs; ++i) {
if (IMAP->flags[i] & IMAP_SELECTED) {
- ++num_selected;
- CtdlCopyMsgToRoom(IMAP->msgids[i], roomname);
+ selected_msgs[num_selected++] = IMAP->msgids[i];
}
}
+ if (num_selected > 0) {
+ CtdlCopyMsgsToRoom(selected_msgs, num_selected, roomname);
+ }
+ free(selected_msgs);
+
/* Don't bother wasting any more time if there were no messages. */
if (num_selected == 0) {
return(0);
}
/* Set the flags... */
- gettimeofday(&tv2, NULL);
i = getroom(&qrbuf, roomname);
if (i == 0) {
- CtdlSetSeen(seen_yes, num_seen_yes, 1,
- ctdlsetseen_seen, NULL, &qrbuf
- );
- CtdlSetSeen(seen_no, num_seen_no, 0,
- ctdlsetseen_seen, NULL, &qrbuf
- );
- CtdlSetSeen(answ_yes, num_answ_yes, 1,
- ctdlsetseen_answered, NULL, &qrbuf
- );
- CtdlSetSeen(answ_no, num_answ_no, 0,
- ctdlsetseen_answered, NULL, &qrbuf
- );
+ CtdlSetSeen(seen_yes, num_seen_yes, 1, ctdlsetseen_seen, NULL, &qrbuf);
+ CtdlSetSeen(seen_no, num_seen_no, 0, ctdlsetseen_seen, NULL, &qrbuf);
+ CtdlSetSeen(answ_yes, num_answ_yes, 1, ctdlsetseen_answered, NULL, &qrbuf);
+ CtdlSetSeen(answ_no, num_answ_no, 0, ctdlsetseen_answered, NULL, &qrbuf);
}
free(seen_yes);
free(answ_yes);
free(answ_no);
- gettimeofday(&tv3, NULL);
- lprintf(CTDL_DEBUG, "Copying pointers: %ld microseconds / Setting flags: %ld microseconds\n",
- (tv2.tv_usec + (tv2.tv_sec * 1000000)) - (tv1.tv_usec + (tv1.tv_sec * 1000000)),
- (tv3.tv_usec + (tv3.tv_sec * 1000000)) - (tv2.tv_usec + (tv2.tv_sec * 1000000))
- );
return(0);
}
long literal_length;
long bytes_transferred;
long stripped_length = 0;
- struct CtdlMessage *msg;
+ struct CtdlMessage *msg = NULL;
long new_msgnum = (-1L);
int ret = 0;
char roomname[ROOMNAMELEN];