Browse Source

Merge branch 'jc/delta' into next

* jc/delta:
  diff-delta: cull collided hash bucket more aggressively.
maint
Junio C Hamano 19 years ago
parent
commit
539d84fe0a
  1. 37
      diff-delta.c

37
diff-delta.c

@ -90,22 +90,35 @@ static struct index ** delta_index(const unsigned char *buf,


/* /*
* Now make sure none of the hash buckets has more entries than * Now make sure none of the hash buckets has more entries than
* we're willing to test. Otherwise we short-circuit the entry * we're willing to test. Otherwise we cull the entry list to
* list uniformly to still preserve a good repartition across * limit identical three byte prefixes to still preserve a good
* the reference buffer. * repartition across the reference buffer.
*/ */
for (i = 0; i < hsize; i++) { for (i = 0; i < hsize; i++) {
struct index **list, *bucket, *remaining;
int cnt;
if (hash_count[i] < hlimit) if (hash_count[i] < hlimit)
continue; continue;
entry = hash[i];
do { bucket = NULL;
struct index *keep = entry; list = &bucket;
int skip = hash_count[i] / hlimit / 2; remaining = hash[i];
do { cnt = 0;
entry = entry->next; while (cnt < hlimit && remaining) {
} while(--skip && entry); struct index *this = remaining, *that;
keep->next = entry; remaining = remaining->next;
} while(entry); for (that = bucket; that; that = that->next) {
if (!memcmp(that->ptr, this->ptr, 3))
break;
}
if (that)
continue; /* discard */
cnt++;
*list = this;
list = &(this->next);
this->next = NULL;
}
hash[i] = bucket;
} }
free(hash_count); free(hash_count);



Loading…
Cancel
Save