diff options
author | Nicolas Pitre <nico@cam.org> | 2007-12-18 10:15:39 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-12-18 15:22:28 -0800 |
commit | ce85b053d827e2f7c2ee2683cc09393e4768cc22 (patch) | |
tree | a08e7d6a0b36a0770a77a74e879451c9833796c3 | |
parent | git-filter-branch.sh: more portable tr usage: use \012, not \n. (diff) | |
download | tgif-ce85b053d827e2f7c2ee2683cc09393e4768cc22.tar.xz |
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>
-rw-r--r-- | diff-delta.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/diff-delta.c b/diff-delta.c index 601b49e37f..a4e28df714 100644 --- a/diff-delta.c +++ b/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) continue; - entries -= hash_count[i] - HASH_LIMIT; /* We leave exactly HASH_LIMIT entries in the bucket */ + entries -= hash_count[i] - HASH_LIMIT; entry = hash[i]; 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 { acc += hash_count[i] - HASH_LIMIT; if (acc > 0) { @@ -229,30 +242,17 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) } entry = entry->next; } 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); - /* 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) + sizeof(*packed_hash) * (hsize+1) + sizeof(*packed_entry) * entries; - mem = malloc(memsize); - if (!mem) { free(hash); return NULL; @@ -269,19 +269,19 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize) mem = packed_hash + (hsize+1); packed_entry = mem; - /* Coalesce all entries belonging to one linked list into - * consecutive array entries */ - for (i = 0; i < hsize; i++) { + /* + * Coalesce all entries belonging to one linked list + * into consecutive array entries. + */ packed_hash[i] = packed_entry; for (entry = hash[i]; entry; entry = entry->next) *packed_entry++ = entry->entry; } - /* Sentinel value to indicate the length of the last hash - * bucket */ - + /* Sentinel value to indicate the length of the last hash bucket */ packed_hash[hsize] = packed_entry; + assert(packed_entry - (struct index_entry *)mem == entries); free(hash); |