commit 69118d25ecb089d083b97cf978047590a5b86e5b
Author: Oswald Buddenhagen <o...@users.sf.net>
Date:   Thu Jan 6 12:44:33 2022 +0100

    optimize { uid => srec } flathash
    
    the sync records contain the uid, so storing it explicitly doubles the
    hash's size for no good reason.

 src/sync.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/src/sync.c b/src/sync.c
index d0dd0561..bc379ea3 100644
--- 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;
                }


_______________________________________________
isync-devel mailing list
isync-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to