int i;
char roomname[ROOMNAMELEN];
struct ctdlroom qrbuf;
+ struct timeval tv1, tv2, tv3;
if (IMAP->num_msgs < 1) {
return(0);
i = imap_grabroom(roomname, destination_folder, 0);
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.
+ *
+ * But the REAL resource waster is further down, where we call
+ * the CtdlSetSeen() API for each message moved. That's a HUGE
+ * performance drag. Fix that too.
+ *
+ */
+ gettimeofday(&tv1, NULL);
for (i = 0; i < IMAP->num_msgs; ++i) {
if (IMAP->flags[i] & IMAP_SELECTED) {
CtdlCopyMsgToRoom(IMAP->msgids[i], roomname);
}
/* Set the flags... */
+ gettimeofday(&tv2, NULL);
i = getroom(&qrbuf, roomname);
if (i != 0) return(i);
for (i = 0; i < IMAP->num_msgs; ++i) {
if (IMAP->flags[i] & IMAP_SELECTED) {
- CtdlSetSeen(IMAP->msgids[i],
+ CtdlSetSeen(&IMAP->msgids[i], 1,
((IMAP->flags[i] & IMAP_SEEN) ? 1 : 0),
ctdlsetseen_seen,
NULL, &qrbuf
);
- CtdlSetSeen(IMAP->msgids[i],
+ CtdlSetSeen(&IMAP->msgids[i], 1,
((IMAP->flags[i] & IMAP_ANSWERED) ? 1 : 0),
ctdlsetseen_answered,
NULL, &qrbuf
}
}
+ gettimeofday(&tv3, NULL);
+ lprintf(CTDL_DEBUG, "Copying the pointers took %ld microseconds\n",
+ (tv2.tv_usec + (tv2.tv_sec * 1000))
+ - (tv1.tv_usec + (tv1.tv_sec * 1000))
+ );
+ lprintf(CTDL_DEBUG, "Setting the flags took %ld microseconds\n",
+ (tv3.tv_usec + (tv3.tv_sec * 1000))
+ - (tv2.tv_usec + (tv2.tv_sec * 1000))
+ );
return(0);
}
extract_token(this_flag, flags, i, ' ', sizeof this_flag);
if (this_flag[0] == '\\') strcpy(this_flag, &this_flag[1]);
if (!strcasecmp(this_flag, "Seen")) {
- CtdlSetSeen(new_msgnum, 1, ctdlsetseen_seen,
+ CtdlSetSeen(&new_msgnum, 1, 1, ctdlsetseen_seen,
NULL, NULL);
}
if (!strcasecmp(this_flag, "Answered")) {
- CtdlSetSeen(new_msgnum, 1, ctdlsetseen_answered,
+ CtdlSetSeen(&new_msgnum, 1, 1, ctdlsetseen_answered,
NULL, NULL);
}
}