commit 69118d25ecb089d083b97cf978047590a5b86e5b
parent 8f4af5f78f118f2e508ca1af7e30d20a3dae8cae
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date: Thu, 6 Jan 2022 12:44:33 +0100
optimize { uid => srec } flathash
the sync records contain the uid, so storing it explicitly doubles the
hash's size for no good reason.
Diffstat:
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/src/sync.c b/src/sync.c
@@ -810,11 +810,6 @@ typedef struct {
int aflags, dflags;
} 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_p2( sync_vars_t *svars, sync_rec_t *srec, 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 )
{
DECL_SVARS;
- sync_rec_t *srec;
- sync_rec_map_t *srecmap;
+ sync_rec_t *srec, **srecmap;
message_t *tmsg;
flag_vars_t *fv;
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)
continue;
idx = (uint)(uid * 1103515245U) % hashsz;
- while (srecmap[idx].uid)
+ while (srecmap[idx])
if (++idx == hashsz)
idx = 0;
- srecmap[idx].uid = uid;
- srecmap[idx].srec = srec;
+ srecmap[idx] = srec;
}
for (tmsg = svars->msgs[t]; tmsg; tmsg = tmsg->next) {
if (tmsg->srec) /* found by TUID */
continue;
uint uid = tmsg->uid;
idx = (uint)(uid * 1103515245U) % hashsz;
- while (srecmap[idx].uid) {
- if (srecmap[idx].uid == uid) {
- srec = srecmap[idx].srec;
+ while ((srec = srecmap[idx])) {
+ if (srec->uid[t] == uid)
goto found;
- }
if (++idx == hashsz)
idx = 0;
}