mutt stable branch with some hacks

Create a uid hash for imap. (see #3905)

This hash will allow for more efficient UID SEARCH processing,
replacing a linear scan with a hash lookup.

+22
+3
imap/imap.c
··· 280 280 FREE (&idata->cache[cacheno].path); 281 281 } 282 282 283 + int_hash_delete (idata->uid_hash, HEADER_DATA(h)->uid, h, NULL); 284 + 283 285 imap_free_header_data ((IMAP_HEADER_DATA**)&h->data); 284 286 } 285 287 } ··· 1392 1394 /* mailbox may not have fully loaded */ 1393 1395 if (ctx->hdrs[i] && ctx->hdrs[i]->data) 1394 1396 imap_free_header_data ((IMAP_HEADER_DATA**)&(ctx->hdrs[i]->data)); 1397 + hash_destroy (&idata->uid_hash, NULL); 1395 1398 1396 1399 for (i = 0; i < IMAP_CACHE_LEN; i++) 1397 1400 {
+1
imap/imap_private.h
··· 214 214 unsigned char reopen; 215 215 unsigned int newMailCount; 216 216 IMAP_CACHE cache[IMAP_CACHE_LEN]; 217 + HASH *uid_hash; 217 218 unsigned int uid_validity; 218 219 unsigned int uidnext; 219 220 body_cache_t *bcache;
+18
imap/message.c
··· 52 52 static int msg_parse_fetch (IMAP_HEADER* h, char* s); 53 53 static char* msg_parse_flags (IMAP_HEADER* h, char* s); 54 54 55 + static void imap_update_context (IMAP_DATA *idata, int oldmsgcount) 56 + { 57 + CONTEXT *ctx; 58 + HEADER *h; 59 + int msgno; 60 + 61 + ctx = idata->ctx; 62 + if (!idata->uid_hash) 63 + idata->uid_hash = int_hash_create (MAX (6 * ctx->msgcount / 5, 30)); 64 + 65 + for (msgno = oldmsgcount; msgno < ctx->msgcount; msgno++) 66 + { 67 + h = ctx->hdrs[msgno]; 68 + int_hash_insert (idata->uid_hash, HEADER_DATA(h)->uid, h, 0); 69 + } 70 + } 71 + 55 72 /* imap_read_headers: 56 73 * Changed to read many headers instead of just one. It will return the 57 74 * msgno of the last message read. It will return a value other than ··· 377 394 { 378 395 mx_alloc_memory(ctx); 379 396 mx_update_context (ctx, ctx->msgcount - oldmsgcount); 397 + imap_update_context (idata, oldmsgcount); 380 398 } 381 399 382 400 idata->reopen |= IMAP_REOPEN_ALLOW;