Browse Source

optimize { uid => srec } flathash

the sync records contain the uid, so storing it explicitly doubles the
hash's size for no good reason.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
69118d25ec
  1. 19
      src/sync.c

19
src/sync.c

@ -810,11 +810,6 @@ typedef struct {
int aflags, dflags; int aflags, dflags;
} flag_vars_t; } flag_vars_t;
typedef struct {
uint uid;
sync_rec_t *srec;
} sync_rec_map_t;
static void flags_set( int sts, void *aux ); static void flags_set( int sts, void *aux );
static void flags_set_p2( sync_vars_t *svars, sync_rec_t *srec, int t ); static void flags_set_p2( sync_vars_t *svars, sync_rec_t *srec, int t );
static void msgs_flags_set( sync_vars_t *svars, int t ); static void msgs_flags_set( sync_vars_t *svars, int t );
@ -825,8 +820,7 @@ static void
box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux ) box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux )
{ {
DECL_SVARS; DECL_SVARS;
sync_rec_t *srec; sync_rec_t *srec, **srecmap;
sync_rec_map_t *srecmap;
message_t *tmsg; message_t *tmsg;
flag_vars_t *fv; flag_vars_t *fv;
int no[2], del[2], alive, todel; int no[2], del[2], alive, todel;
@ -856,22 +850,19 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
if (!uid) if (!uid)
continue; continue;
idx = (uint)(uid * 1103515245U) % hashsz; idx = (uint)(uid * 1103515245U) % hashsz;
while (srecmap[idx].uid) while (srecmap[idx])
if (++idx == hashsz) if (++idx == hashsz)
idx = 0; idx = 0;
srecmap[idx].uid = uid; srecmap[idx] = srec;
srecmap[idx].srec = srec;
} }
for (tmsg = svars->msgs[t]; tmsg; tmsg = tmsg->next) { for (tmsg = svars->msgs[t]; tmsg; tmsg = tmsg->next) {
if (tmsg->srec) /* found by TUID */ if (tmsg->srec) /* found by TUID */
continue; continue;
uint uid = tmsg->uid; uint uid = tmsg->uid;
idx = (uint)(uid * 1103515245U) % hashsz; idx = (uint)(uid * 1103515245U) % hashsz;
while (srecmap[idx].uid) { while ((srec = srecmap[idx])) {
if (srecmap[idx].uid == uid) { if (srec->uid[t] == uid)
srec = srecmap[idx].srec;
goto found; goto found;
}
if (++idx == hashsz) if (++idx == hashsz)
idx = 0; idx = 0;
} }

Loading…
Cancel
Save