mutt stable branch with some hacks

Convert cmd_parse_search to use the uid hash. (closes #3905)

Replace the linear scan for each result with a hash lookup. This
should greatly improve performance for large mailboxes.

+5 -21
+5 -21
imap/command.c
··· 855 855 } 856 856 } 857 857 858 - /* This should be optimised (eg with a tree or hash) */ 859 - static int uid2msgno (IMAP_DATA* idata, unsigned int uid) 860 - { 861 - int i; 862 - 863 - for (i = 0; i < idata->ctx->msgcount; i++) 864 - { 865 - HEADER* h = idata->ctx->hdrs[i]; 866 - if (HEADER_DATA(h)->uid == uid) 867 - return i; 868 - } 869 - 870 - return -1; 871 - } 872 - 873 858 /* cmd_parse_search: store SEARCH response for later use */ 874 859 static void cmd_parse_search (IMAP_DATA* idata, const char* s) 875 860 { 876 861 unsigned int uid; 877 - int msgno; 862 + HEADER *h; 878 863 879 864 dprint (2, (debugfile, "Handling SEARCH\n")); 880 865 881 866 while ((s = imap_next_word ((char*)s)) && *s != '\0') 882 867 { 883 - uid = atoi (s); 884 - msgno = uid2msgno (idata, uid); 885 - 886 - if (msgno >= 0) 887 - idata->ctx->hdrs[msgno]->matched = 1; 868 + uid = (unsigned int)atoi (s); 869 + h = (HEADER *)int_hash_find (idata->uid_hash, uid); 870 + if (h) 871 + h->matched = 1; 888 872 } 889 873 } 890 874