From 4a456661fc5540a3c03cca33d025953490e6554e Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Mon, 5 Mar 2012 22:35:18 +0100 Subject: [PATCH] CtdlDeleteMessages(): deploy smarter logic to check which messages are to be deleted - sort the to be deleted message list before starting to search them inside of the list of messages in this room - before: compare each in the roomlist to each in the delete list. - after: fast forward over the room-messagelist while the message id is smaller than the currently to be checked delete message ID. --- citadel/msgbase.c | 48 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/citadel/msgbase.c b/citadel/msgbase.c index a842394b8..a2110912c 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -4699,32 +4699,51 @@ int CtdlDeleteMessages(char *room_name, /* which room */ cdb_free(cdbfr); } if (num_msgs > 0) { - for (i = 0; i < num_msgs; ++i) { + int have_contenttype = !IsEmptyStr(content_type); + int have_delmsgs = (num_dmsgnums == 0) || (dmsgnums == NULL); + int have_more_del = 1; + + num_msgs = sort_msglist(msglist, num_msgs); + if (num_dmsgnums > 1) + num_dmsgnums = sort_msglist(dmsgnums, num_dmsgnums); +/* + { + StrBuf *dbg = NewStrBuf(); + for (i = 0; i < num_dmsgnums; i++) + StrBufAppendPrintf(dbg, ", %ld", dmsgnums[i]); + syslog(LOG_DEBUG, "Deleting before: %s", ChrPtr(dbg)); + FreeStrBuf(&dbg); + } +*/ + i = 0; j = 0; + while ((i < num_msgs) && (have_more_del)) { delete_this = 0x00; + /* Set/clear a bit for each criterion */ /* 0 messages in the list or a null list means that we are * interested in deleting any messages which meet the other criteria. */ - if ((num_dmsgnums == 0) || (dmsgnums == NULL)) { + if (have_delmsgs) { delete_this |= 0x01; } else { - for (j=0; j