- do {
-- tag t = gettag2(s1,s2);
-+ uint32 t = gettag2(s1,s2);
- int done_csum2 = 0;
-- int32 j = tag_table[t];
-+ int32 i;
-
- if (verbose > 4)
- rprintf(FINFO,"offset=%.0f sum=%08x\n",(double)offset,sum);
-
-- if (j == NULL_TAG)
-- goto null_tag;
--
- sum = (s1 & 0xffff) | (s2 << 16);
- tag_hits++;
-- do {
-- int32 l, i = targets[j].i;
-+ for (i = sum_table[t]; i >= 0; i = s->sums[i].chain) {
-+ int32 l;
-
- if (sum != s->sums[i].sum1)
- continue;
-@@ -205,9 +187,10 @@ static void hash_search(int f,struct sum
- && !(s->sums[i].flags & SUMFLG_SAME_OFFSET))
- continue;
-
-- if (verbose > 3)
-- rprintf(FINFO,"potential match at %.0f target=%.0f %.0f sum=%08x\n",
-- (double)offset,(double)j,(double)i,sum);
-+ if (verbose > 3) {
-+ rprintf(FINFO,"potential match at %.0f i=%ld sum=%08x\n",
-+ (double)offset, (long)i, sum);
-+ }
-
- if (!done_csum2) {
- map = (schar *)map_ptr(buf,offset,l);
-@@ -224,23 +207,23 @@ static void hash_search(int f,struct sum
- * one with an identical offset, so we prefer that over
- * the following want_i optimization. */
- if (updating_basis_file) {
-- do {
-- int32 i2 = targets[j].i;
-+ int32 i2;
-+ for (i2 = i; i2 >= 0; i2 = s->sums[i2].chain) {
- if (s->sums[i2].offset != offset)
- continue;
- if (i2 != i) {
- if (sum != s->sums[i2].sum1)
-- break;
-+ continue;
- if (memcmp(sum2, s->sums[i2].sum2,
- s->s2length) != 0)
-- break;
-+ continue;
- i = i2;
- }
- /* This chunk was at the same offset on
- * both the sender and the receiver. */
- s->sums[i].flags |= SUMFLG_SAME_OFFSET;
- goto set_want_i;
-- } while (++j < s->count && targets[j].t == t);
-+ }
- }
-
- /* we've found a match, but now check to see
-@@ -266,9 +249,8 @@ static void hash_search(int f,struct sum
- s2 = sum >> 16;
- matches++;
- break;
-- } while (++j < s->count && targets[j].t == t);
+@@ -164,11 +185,16 @@ static void hash_search(int f,struct sum
+ (double)offset, s2 & 0xFFFF, s1 & 0xFFFF);
+ }
+
+- i = hash_table[SUM2HASH2(s1,s2)];
+- if (i < 0)
+- goto null_hash;
++ if (tablesize == TRADITIONAL_TABLESIZE) {
++ if ((i = hash_table[SUM2HASH2(s1,s2)]) < 0)
++ goto null_hash;
++ sum = (s1 & 0xffff) | (s2 << 16);
++ } else {
++ sum = (s1 & 0xffff) | (s2 << 16);
++ if ((i = hash_table[BIG_SUM2HASH(sum)]) < 0)
++ goto null_hash;