summaryrefslogtreecommitdiffstats
path: root/mh.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2017-09-25 18:40:32 -0700
committerKevin McCarthy <kevin@8t8.us>2017-09-25 18:40:32 -0700
commitbf34a03801d11eab6976a195a580a8593a193a65 (patch)
treeead8ab432218e3610149ff40ec32131c454f78d0 /mh.c
parentf5935f3d1d6db2d3cc38dafce0acd67fd136c8bf (diff)
Change maildir and mh check_mailbox to use dynamic sized hash. (closes #3973)
The original patch is by Matt Fleming, originally posted at http://www.codeblueprint.co.uk/2017/01/15/a-kernel-devs-approach-to-improving2 The comments there indicate Matt tried to submit to trac and mutt-dev, but ran into registration problems. Thank you for the patch, and sorry for those problems, Matt. I modified the patch by making the same change to the mh_check_mailbox() code too.
Diffstat (limited to 'mh.c')
-rw-r--r--mh.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/mh.c b/mh.c
index 060368e9..2618fe12 100644
--- a/mh.c
+++ b/mh.c
@@ -2095,6 +2095,7 @@ static int maildir_check_mailbox (CONTEXT * ctx, int *index_hint)
struct maildir *md; /* list of messages in the mailbox */
struct maildir **last, *p;
int i;
+ int count = 0;
HASH *fnames; /* hash table for quickly looking up the base filename
for a maildir message */
struct mh_data *data = mh_data (ctx);
@@ -2132,15 +2133,15 @@ static int maildir_check_mailbox (CONTEXT * ctx, int *index_hint)
md = NULL;
last = &md;
if (changed & 1)
- maildir_parse_dir (ctx, &last, "new", NULL, NULL);
+ maildir_parse_dir (ctx, &last, "new", &count, NULL);
if (changed & 2)
- maildir_parse_dir (ctx, &last, "cur", NULL, NULL);
+ maildir_parse_dir (ctx, &last, "cur", &count, NULL);
/* we create a hash table keyed off the canonical (sans flags) filename
* of each message we scanned. This is used in the loop over the
* existing messages below to do some correlation.
*/
- fnames = hash_create (1031, 0);
+ fnames = hash_create (count, 0);
for (p = md; p; p = p->next)
{
@@ -2248,6 +2249,7 @@ static int mh_check_mailbox (CONTEXT * ctx, int *index_hint)
struct maildir *md, *p;
struct maildir **last = NULL;
struct mh_sequences mhs;
+ int count = 0;
HASH *fnames;
int i;
struct mh_data *data = mh_data (ctx);
@@ -2292,7 +2294,7 @@ static int mh_check_mailbox (CONTEXT * ctx, int *index_hint)
md = NULL;
last = &md;
- maildir_parse_dir (ctx, &last, NULL, NULL, NULL);
+ maildir_parse_dir (ctx, &last, NULL, &count, NULL);
maildir_delayed_parsing (ctx, &md, NULL);
if (mh_read_sequences (&mhs, ctx->path) < 0)
@@ -2301,7 +2303,7 @@ static int mh_check_mailbox (CONTEXT * ctx, int *index_hint)
mhs_free_sequences (&mhs);
/* check for modifications and adjust flags */
- fnames = hash_create (1031, 0);
+ fnames = hash_create (count, 0);
for (p = md; p; p = p->next)
{