@matheusbsbs / matheus-bagliano / commits / ce85b053d8
Fork 0

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>

Nicolas Pitre committed Dec 18, 2007 at 10:15 UTC ce85b053d827e2f7c2ee2683cc09393e4768cc22
1 file changed +24 -24
diff-delta.c
+24 -24
@@ -212,11 +212,24 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
212 if (hash_count[i] <= HASH_LIMIT)
213 continue;
214
215 - entries -= hash_count[i] - HASH_LIMIT;
215 /* We leave exactly HASH_LIMIT entries in the bucket */
216 + entries -= hash_count[i] - HASH_LIMIT;
217
218 entry = hash[i];
219 acc = 0;
220 +
221 + /*
222 + * Assume that this loop is gone through exactly
223 + * HASH_LIMIT times and is entered and left with
224 + * acc==0. So the first statement in the loop
225 + * contributes (hash_count[i]-HASH_LIMIT)*HASH_LIMIT
226 + * to the accumulator, and the inner loop consequently
227 + * is run (hash_count[i]-HASH_LIMIT) times, removing
228 + * one element from the list each time. Since acc
229 + * balances out to 0 at the final run, the inner loop
230 + * body can't be left with entry==NULL. So we indeed
231 + * encounter entry==NULL in the outer loop only.
232 + */
233 do {
234 acc += hash_count[i] - HASH_LIMIT;
235 if (acc > 0) {
@@ -229,30 +242,17 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
242 }
243 entry = entry->next;
244 } while (entry);
232 -
233 - /* Assume that this loop is gone through exactly
234 - * HASH_LIMIT times and is entered and left with
235 - * acc==0. So the first statement in the loop
236 - * contributes (hash_count[i]-HASH_LIMIT)*HASH_LIMIT
237 - * to the accumulator, and the inner loop consequently
238 - * is run (hash_count[i]-HASH_LIMIT) times, removing
239 - * one element from the list each time. Since acc
240 - * balances out to 0 at the final run, the inner loop
241 - * body can't be left with entry==NULL. So we indeed
242 - * encounter entry==NULL in the outer loop only.
243 - */
245 }
246 free(hash_count);
247
247 - /* Now create the packed index in array form rather than
248 - * linked lists */
249 -
248 + /*
249 + * Now create the packed index in array form
250 + * rather than linked lists.
251 + */
252 memsize = sizeof(*index)
253 + sizeof(*packed_hash) * (hsize+1)
254 + sizeof(*packed_entry) * entries;
253 -
255 mem = malloc(memsize);
255 -
256 if (!mem) {
257 free(hash);
258 return NULL;
@@ -269,19 +269,19 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
269 mem = packed_hash + (hsize+1);
270 packed_entry = mem;
271
272 - /* Coalesce all entries belonging to one linked list into
273 - * consecutive array entries */
274 -
272 for (i = 0; i < hsize; i++) {
273 + /*
274 + * Coalesce all entries belonging to one linked list
275 + * into consecutive array entries.
276 + */
277 packed_hash[i] = packed_entry;
278 for (entry = hash[i]; entry; entry = entry->next)
279 *packed_entry++ = entry->entry;
280 }
281
281 - /* Sentinel value to indicate the length of the last hash
282 - * bucket */
283 -
282 + /* Sentinel value to indicate the length of the last hash bucket */
283 packed_hash[hsize] = packed_entry;
284 +
285 assert(packed_entry - (struct index_entry *)mem == entries);
286 free(hash);
287