{"thread":{"id":"11343","subject":"[PATCH] fix style of a few comments in diff-delta.c","startedAt":"2007-12-18T15:15:39Z","lastAt":"2007-12-18T15:15:39Z","messageCount":1,"participants":["Nicolas Pitre"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"63619","messageId":"alpine.LFD.0.999999.0712181012350.8467@xanadu.home","threadId":"11343","inReplyTo":null,"subject":"[PATCH] fix style of a few comments in diff-delta.c","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2007-12-18T15:15:39Z","receivedAt":"2007-12-18T15:15:39Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"Signed-off-by: Nicolas Pitre <nico@cam.org>\n---\ndiff --git a/diff-delta.c b/diff-delta.c\nindex 601b49e..a4e28df 100644\n--- a/diff-delta.c\n+++ b/diff-delta.c\n@@ -212,11 +212,24 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n \t\tif (hash_count[i] <= HASH_LIMIT)\n \t\t\tcontinue;\n \n-\t\tentries -= hash_count[i] - HASH_LIMIT;\n \t\t/* We leave exactly HASH_LIMIT entries in the bucket */\n+\t\tentries -= hash_count[i] - HASH_LIMIT;\n \n \t\tentry = hash[i];\n \t\tacc = 0;\n+\n+\t\t/*\n+\t\t * Assume that this loop is gone through exactly\n+\t\t * HASH_LIMIT times and is entered and left with\n+\t\t * acc==0.  So the first statement in the loop\n+\t\t * contributes (hash_count[i]-HASH_LIMIT)*HASH_LIMIT\n+\t\t * to the accumulator, and the inner loop consequently\n+\t\t * is run (hash_count[i]-HASH_LIMIT) times, removing\n+\t\t * one element from the list each time.  Since acc\n+\t\t * balances out to 0 at the final run, the inner loop\n+\t\t * body can't be left with entry==NULL.  So we indeed\n+\t\t * encounter entry==NULL in the outer loop only.\n+\t\t */\n \t\tdo {\n \t\t\tacc += hash_count[i] - HASH_LIMIT;\n \t\t\tif (acc > 0) {\n@@ -229,30 +242,17 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n \t\t\t}\n \t\t\tentry = entry->next;\n \t\t} while (entry);\n-\n-\t\t/* Assume that this loop is gone through exactly\n-\t\t * HASH_LIMIT times and is entered and left with\n-\t\t * acc==0.  So the first statement in the loop\n-\t\t * contributes (hash_count[i]-HASH_LIMIT)*HASH_LIMIT\n-\t\t * to the accumulator, and the inner loop consequently\n-\t\t * is run (hash_count[i]-HASH_LIMIT) times, removing\n-\t\t * one element from the list each time.  Since acc\n-\t\t * balances out to 0 at the final run, the inner loop\n-\t\t * body can't be left with entry==NULL.  So we indeed\n-\t\t * encounter entry==NULL in the outer loop only.\n-\t\t */\n \t}\n \tfree(hash_count);\n \n-\t/* Now create the packed index in array form rather than\n-\t * linked lists */\n-\n+\t/*\n+\t * Now create the packed index in array form\n+\t * rather than linked lists.\n+\t */\n \tmemsize = sizeof(*index)\n \t\t+ sizeof(*packed_hash) * (hsize+1)\n \t\t+ sizeof(*packed_entry) * entries;\n-\n \tmem = malloc(memsize);\n-\n \tif (!mem) {\n \t\tfree(hash);\n \t\treturn NULL;\n@@ -269,19 +269,19 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)\n \tmem = packed_hash + (hsize+1);\n \tpacked_entry = mem;\n \n-\t/* Coalesce all entries belonging to one linked list into\n-\t * consecutive array entries */\n-\n \tfor (i = 0; i < hsize; i++) {\n+\t\t/*\n+\t\t * Coalesce all entries belonging to one linked list\n+\t\t * into consecutive array entries.\n+\t\t */\n \t\tpacked_hash[i] = packed_entry;\n \t\tfor (entry = hash[i]; entry; entry = entry->next)\n \t\t\t*packed_entry++ = entry->entry;\n \t}\n \n-\t/* Sentinel value to indicate the length of the last hash\n-\t * bucket */\n-\n+\t/* Sentinel value to indicate the length of the last hash bucket */\n \tpacked_hash[hsize] = packed_entry;\n+\n \tassert(packed_entry - (struct index_entry *)mem == entries);\n \tfree(hash);\n \n"}]}