X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/edecdad54de4c47609319d469ec41fbd36c0ab35..066a844c4e51b1a2c6528dfd2deed283292a68b5:/match.c diff --git a/match.c b/match.c index 6909fca3..8ddbf92b 100644 --- a/match.c +++ b/match.c @@ -22,6 +22,7 @@ extern int verbose; extern int am_server; extern int do_progress; +extern int checksum_seed; typedef unsigned short tag; @@ -187,7 +188,7 @@ static void hash_search(int f,struct sum_struct *s, sum = (s1 & 0xffff) | (s2 << 16); tag_hits++; - for (; j < s->count && targets[j].t == t; j++) { + do { unsigned int l; size_t i = targets[j].i; @@ -216,20 +217,13 @@ static void hash_search(int f,struct sum_struct *s, /* we've found a match, but now check to see * if last_i can hint at a better match */ - for (j++; j < s->count && targets[j].t == t; j++) { - size_t i2 = targets[j].i; - if (i2 == last_i + 1) { - if (sum != s->sums[i2].sum1) - break; - if (memcmp(sum2,s->sums[i2].sum2,s->s2length) != 0) - break; - /* we've found an adjacent match - the RLL coder - * will be happy */ - i = i2; - break; - } + if (i != last_i + 1 && last_i + 1 < s->count + && sum == s->sums[last_i+1].sum1 + && memcmp(sum2, s->sums[last_i+1].sum2, s->s2length) == 0) { + /* we've found an adjacent match - the RLL coder + * will be happy */ + i = last_i + 1; } - last_i = i; matched(f,s,buf,offset,i); @@ -241,7 +235,7 @@ static void hash_search(int f,struct sum_struct *s, s2 = sum >> 16; matches++; break; - } + } while (++j < s->count && targets[j].t == t); null_tag: /* Trim off the first byte from the checksum */ @@ -299,7 +293,7 @@ void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len) matches = 0; data_transfer = 0; - sum_init(); + sum_init(checksum_seed); if (len > 0 && s->count>0) { build_hash_table(s);