fix style of a few comments in diff-delta.c
Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e8a3f90994
commit
ce85b053d8
48
diff-delta.c
48
diff-delta.c
@ -212,11 +212,24 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
|
|||||||
if (hash_count[i] <= HASH_LIMIT)
|
if (hash_count[i] <= HASH_LIMIT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
entries -= hash_count[i] - HASH_LIMIT;
|
|
||||||
/* We leave exactly HASH_LIMIT entries in the bucket */
|
/* We leave exactly HASH_LIMIT entries in the bucket */
|
||||||
|
entries -= hash_count[i] - HASH_LIMIT;
|
||||||
|
|
||||||
entry = hash[i];
|
entry = hash[i];
|
||||||
acc = 0;
|
acc = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assume that this loop is gone through exactly
|
||||||
|
* HASH_LIMIT times and is entered and left with
|
||||||
|
* acc==0. So the first statement in the loop
|
||||||
|
* contributes (hash_count[i]-HASH_LIMIT)*HASH_LIMIT
|
||||||
|
* to the accumulator, and the inner loop consequently
|
||||||
|
* is run (hash_count[i]-HASH_LIMIT) times, removing
|
||||||
|
* one element from the list each time. Since acc
|
||||||
|
* balances out to 0 at the final run, the inner loop
|
||||||
|
* body can't be left with entry==NULL. So we indeed
|
||||||
|
* encounter entry==NULL in the outer loop only.
|
||||||
|
*/
|
||||||
do {
|
do {
|
||||||
acc += hash_count[i] - HASH_LIMIT;
|
acc += hash_count[i] - HASH_LIMIT;
|
||||||
if (acc > 0) {
|
if (acc > 0) {
|
||||||
@ -229,30 +242,17 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
|
|||||||
}
|
}
|
||||||
entry = entry->next;
|
entry = entry->next;
|
||||||
} while (entry);
|
} while (entry);
|
||||||
|
|
||||||
/* Assume that this loop is gone through exactly
|
|
||||||
* HASH_LIMIT times and is entered and left with
|
|
||||||
* acc==0. So the first statement in the loop
|
|
||||||
* contributes (hash_count[i]-HASH_LIMIT)*HASH_LIMIT
|
|
||||||
* to the accumulator, and the inner loop consequently
|
|
||||||
* is run (hash_count[i]-HASH_LIMIT) times, removing
|
|
||||||
* one element from the list each time. Since acc
|
|
||||||
* balances out to 0 at the final run, the inner loop
|
|
||||||
* body can't be left with entry==NULL. So we indeed
|
|
||||||
* encounter entry==NULL in the outer loop only.
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
free(hash_count);
|
free(hash_count);
|
||||||
|
|
||||||
/* Now create the packed index in array form rather than
|
/*
|
||||||
* linked lists */
|
* Now create the packed index in array form
|
||||||
|
* rather than linked lists.
|
||||||
|
*/
|
||||||
memsize = sizeof(*index)
|
memsize = sizeof(*index)
|
||||||
+ sizeof(*packed_hash) * (hsize+1)
|
+ sizeof(*packed_hash) * (hsize+1)
|
||||||
+ sizeof(*packed_entry) * entries;
|
+ sizeof(*packed_entry) * entries;
|
||||||
|
|
||||||
mem = malloc(memsize);
|
mem = malloc(memsize);
|
||||||
|
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
free(hash);
|
free(hash);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -269,19 +269,19 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
|
|||||||
mem = packed_hash + (hsize+1);
|
mem = packed_hash + (hsize+1);
|
||||||
packed_entry = mem;
|
packed_entry = mem;
|
||||||
|
|
||||||
/* Coalesce all entries belonging to one linked list into
|
|
||||||
* consecutive array entries */
|
|
||||||
|
|
||||||
for (i = 0; i < hsize; i++) {
|
for (i = 0; i < hsize; i++) {
|
||||||
|
/*
|
||||||
|
* Coalesce all entries belonging to one linked list
|
||||||
|
* into consecutive array entries.
|
||||||
|
*/
|
||||||
packed_hash[i] = packed_entry;
|
packed_hash[i] = packed_entry;
|
||||||
for (entry = hash[i]; entry; entry = entry->next)
|
for (entry = hash[i]; entry; entry = entry->next)
|
||||||
*packed_entry++ = entry->entry;
|
*packed_entry++ = entry->entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sentinel value to indicate the length of the last hash
|
/* Sentinel value to indicate the length of the last hash bucket */
|
||||||
* bucket */
|
|
||||||
|
|
||||||
packed_hash[hsize] = packed_entry;
|
packed_hash[hsize] = packed_entry;
|
||||||
|
|
||||||
assert(packed_entry - (struct index_entry *)mem == entries);
|
assert(packed_entry - (struct index_entry *)mem == entries);
|
||||||
free(hash);
|
free(hash);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user