{"thread":{"id":"50376","subject":"[PATCH 3/3] It's C not C++ so variable length array should not be used [-Werror=vla] :,).","startedAt":"2019-02-01T08:36:17Z","lastAt":"2019-02-04T17:56:28Z","messageCount":9,"participants":["Shahzad Lone","Eric Sunshine","Brandon Richardson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"368311","messageId":"01020168a8338127-d50bd8d1-c178-4f13-86b1-9a191f64ded0-000000@eu-west-1.amazonses.com","threadId":"50376","inReplyTo":"01020168a8338064-b1c054c4-3e05-4825-b8dc-636d9c63dcfc-000000@eu-west-1.amazonses.com","subject":"[PATCH 3/3] It's C not C++ so variable length array should not be used [-Werror=vla] :,).","fromName":"Shahzad Lone","fromEmail":"shahzadlone@gmail.com","sentAt":"2019-02-01T08:36:14Z","receivedAt":"2019-02-01T08:36:17Z","isPatch":true,"sender":{"key":"shahzadlone@gmail.com","avatar":"https://avatars.githubusercontent.com/u/30120428?v=4"},"body":"---\n builtin/pack-objects.c | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex c1ec9ef3232cb..3017beb8236fa 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -197,9 +197,8 @@ static unsigned long write_large_blob_data(struct git_istream *st, struct hashfi\n \t\t\t\t\t   const struct object_id *oid)\n {\n \tgit_zstream stream;\n-\tconst unsigned bufsize = 16384;\n-\tunsigned char ibuf[bufsize];\n-\tunsigned char obuf[bufsize];\n+\tunsigned char ibuf[16384];\n+\tunsigned char obuf[16384];\n \tunsigned long olen = 0;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n\n--\nhttps://github.com/git/git/pull/572\n"},{"id":"368312","messageId":"01020168a83380fb-ecad8400-915d-497c-841f-096541747cd6-000000@eu-west-1.amazonses.com","threadId":"50376","inReplyTo":"01020168a8338064-b1c054c4-3e05-4825-b8dc-636d9c63dcfc-000000@eu-west-1.amazonses.com","subject":"[PATCH 2/3] ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] so fix that.","fromName":"Shahzad Lone","fromEmail":"shahzadlone@gmail.com","sentAt":"2019-02-01T08:36:14Z","receivedAt":"2019-02-01T08:36:19Z","isPatch":true,"sender":{"key":"shahzadlone@gmail.com","avatar":"https://avatars.githubusercontent.com/u/30120428?v=4"},"body":"---\n pack-revindex.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/pack-revindex.c b/pack-revindex.c\nindex 202981b39c6b6..40651ec9fac2e 100644\n--- a/pack-revindex.c\n+++ b/pack-revindex.c\n@@ -186,9 +186,9 @@ int find_revindex_position(struct packed_git *p, off_t ofs)\n \n struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs)\n {\n-\n+\tint pos;\n \tload_pack_revindex(p);\n-\tconst int pos = find_revindex_position(p, ofs);\n+\tpos = find_revindex_position(p, ofs);\n \n \tif (pos < 0)\n \t\treturn NULL;\n\n--\nhttps://github.com/git/git/pull/572\n"},{"id":"368313","messageId":"01020168a8338064-b1c054c4-3e05-4825-b8dc-636d9c63dcfc-000000@eu-west-1.amazonses.com","threadId":"50376","inReplyTo":null,"subject":"[PATCH 1/3] [Enhancement] Improve internals / refactoring.","fromName":"Shahzad Lone","fromEmail":"shahzadlone@gmail.com","sentAt":"2019-02-01T08:36:14Z","receivedAt":"2019-02-01T08:36:19Z","isPatch":true,"sender":{"key":"shahzadlone@gmail.com","avatar":"https://avatars.githubusercontent.com/u/30120428?v=4"},"body":"Changed to ```consts``` and tried to save arithmetic cost where I could.\n\nSorry my coding OCD bothered me when I didn't see them being ```consts```.\n---\n builtin/diff.c           |  2 +-\n builtin/pack-objects.c   | 19 ++++++++++---------\n builtin/pack-redundant.c |  4 ++--\n pack-revindex.c          | 13 ++++++-------\n 4 files changed, 19 insertions(+), 19 deletions(-)\n\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex f0393bba23a7d..84a362ff5625b 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -102,7 +102,7 @@ static int builtin_diff_blobs(struct rev_info *revs,\n \t\t\t      int argc, const char **argv,\n \t\t\t      struct object_array_entry **blob)\n {\n-\tunsigned mode = canon_mode(S_IFREG | 0644);\n+\tconst unsigned mode = canon_mode(S_IFREG | 0644);\n \n \tif (argc > 1)\n \t\tusage(builtin_diff_usage);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 0a70d046043ec..c1ec9ef3232cb 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -197,8 +197,9 @@ static unsigned long write_large_blob_data(struct git_istream *st, struct hashfi\n \t\t\t\t\t   const struct object_id *oid)\n {\n \tgit_zstream stream;\n-\tunsigned char ibuf[1024 * 16];\n-\tunsigned char obuf[1024 * 16];\n+\tconst unsigned bufsize = 16384;\n+\tunsigned char ibuf[bufsize];\n+\tunsigned char obuf[bufsize];\n \tunsigned long olen = 0;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n@@ -1901,10 +1902,10 @@ static int type_size_sort(const void *_a, const void *_b)\n {\n \tconst struct object_entry *a = *(struct object_entry **)_a;\n \tconst struct object_entry *b = *(struct object_entry **)_b;\n-\tenum object_type a_type = oe_type(a);\n-\tenum object_type b_type = oe_type(b);\n-\tunsigned long a_size = SIZE(a);\n-\tunsigned long b_size = SIZE(b);\n+\tconst enum object_type a_type = oe_type(a);\n+\tconst enum object_type b_type = oe_type(b);\n+\tconst unsigned long a_size = SIZE(a);\n+\tconst unsigned long b_size = SIZE(b);\n \n \tif (a_type > b_type)\n \t\treturn -1;\n@@ -1919,7 +1920,7 @@ static int type_size_sort(const void *_a, const void *_b)\n \tif (a->preferred_base < b->preferred_base)\n \t\treturn 1;\n \tif (use_delta_islands) {\n-\t\tint island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid);\n+\t\tconst int island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid);\n \t\tif (island_cmp)\n \t\t\treturn island_cmp;\n \t}\n@@ -2171,7 +2172,7 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)\n \tstruct object_entry *child = DELTA_CHILD(me);\n \tunsigned int m = n;\n \twhile (child) {\n-\t\tunsigned int c = check_delta_limit(child, n + 1);\n+\t\tconst unsigned int c = check_delta_limit(child, n + 1);\n \t\tif (m < c)\n \t\t\tm = c;\n \t\tchild = DELTA_SIBLING(child);\n@@ -2226,7 +2227,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n \t\twhile (window_memory_limit &&\n \t\t       mem_usage > window_memory_limit &&\n \t\t       count > 1) {\n-\t\t\tuint32_t tail = (idx + window - count) % window;\n+\t\t\tconst uint32_t tail = (idx + window - count) % window;\n \t\t\tmem_usage -= free_unpacked(array + tail);\n \t\t\tcount--;\n \t\t}\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex cf9a9aabd4eb2..11bc51456631e 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -166,7 +166,7 @@ static inline struct llist_item * llist_sorted_remove(struct llist *list, const\n \tl = (hint == NULL) ? list->front : hint;\n \tprev = NULL;\n \twhile (l) {\n-\t\tint cmp = oidcmp(l->oid, oid);\n+\t\tconst int cmp = oidcmp(l->oid, oid);\n \t\tif (cmp > 0) /* not in list, since sorted */\n \t\t\treturn prev;\n \t\tif (!cmp) { /* found */\n@@ -264,7 +264,7 @@ static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)\n \twhile (p1_off < p1->pack->num_objects * p1_step &&\n \t       p2_off < p2->pack->num_objects * p2_step)\n \t{\n-\t\tint cmp = hashcmp(p1_base + p1_off, p2_base + p2_off);\n+\t\tconst int cmp = hashcmp(p1_base + p1_off, p2_base + p2_off);\n \t\t/* cmp ~ p1 - p2 */\n \t\tif (cmp == 0) {\n \t\t\tp1_hint = llist_sorted_remove(p1->unique_objects,\ndiff --git a/pack-revindex.c b/pack-revindex.c\nindex 3c58784a5f4de..202981b39c6b6 100644\n--- a/pack-revindex.c\n+++ b/pack-revindex.c\n@@ -119,7 +119,7 @@ static void sort_revindex(struct revindex_entry *entries, unsigned n, off_t max)\n  */\n static void create_pack_revindex(struct packed_git *p)\n {\n-\tunsigned num_ent = p->num_objects;\n+\tconst unsigned num_ent = p->num_objects;\n \tunsigned i;\n \tconst char *index = p->index_data;\n \tconst unsigned hashsz = the_hash_algo->rawsz;\n@@ -132,7 +132,7 @@ static void create_pack_revindex(struct packed_git *p)\n \t\t\t(uint32_t *)(index + 8 + p->num_objects * (hashsz + 4));\n \t\tconst uint32_t *off_64 = off_32 + p->num_objects;\n \t\tfor (i = 0; i < num_ent; i++) {\n-\t\t\tuint32_t off = ntohl(*off_32++);\n+\t\t\tconst uint32_t off = ntohl(*off_32++);\n \t\t\tif (!(off & 0x80000000)) {\n \t\t\t\tp->revindex[i].offset = off;\n \t\t\t} else {\n@@ -143,7 +143,7 @@ static void create_pack_revindex(struct packed_git *p)\n \t\t}\n \t} else {\n \t\tfor (i = 0; i < num_ent; i++) {\n-\t\t\tuint32_t hl = *((uint32_t *)(index + (hashsz + 4) * i));\n+\t\t\tconst uint32_t hl = *((uint32_t *)(index + (hashsz + 4) * i));\n \t\t\tp->revindex[i].offset = ntohl(hl);\n \t\t\tp->revindex[i].nr = i;\n \t\t}\n@@ -168,10 +168,10 @@ int find_revindex_position(struct packed_git *p, off_t ofs)\n {\n \tint lo = 0;\n \tint hi = p->num_objects + 1;\n-\tstruct revindex_entry *revindex = p->revindex;\n+\tconst struct revindex_entry *revindex = p->revindex;\n \n \tdo {\n-\t\tunsigned mi = lo + (hi - lo) / 2;\n+\t\tconst unsigned mi = lo + (hi - lo) / 2;\n \t\tif (revindex[mi].offset == ofs) {\n \t\t\treturn mi;\n \t\t} else if (ofs < revindex[mi].offset)\n@@ -186,10 +186,9 @@ int find_revindex_position(struct packed_git *p, off_t ofs)\n \n struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs)\n {\n-\tint pos;\n \n \tload_pack_revindex(p);\n-\tpos = find_revindex_position(p, ofs);\n+\tconst int pos = find_revindex_position(p, ofs);\n \n \tif (pos < 0)\n \t\treturn NULL;\n\n--\nhttps://github.com/git/git/pull/572\n"},{"id":"368314","messageId":"CAPig+cTEZVt13XBQ9z7aQp0PAZQbN5xRm+PC16iSNNr=G473YQ@mail.gmail.com","threadId":"50376","inReplyTo":"01020168a83380fb-ecad8400-915d-497c-841f-096541747cd6-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH 2/3] ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] so fix that.","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-02-01T09:00:00Z","receivedAt":"2019-02-01T09:00:16Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Feb 1, 2019 at 3:36 AM Shahzad Lone <shahzadlone@gmail.com> wrote:\n> diff --git a/pack-revindex.c b/pack-revindex.c\n> @@ -186,9 +186,9 @@ int find_revindex_position(struct packed_git *p, off_t ofs)\n>  struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs)\n>  {\n> -\n> +       int pos;\n>         load_pack_revindex(p);\n> -       const int pos = find_revindex_position(p, ofs);\n> +       pos = find_revindex_position(p, ofs);\n\nThanks, however, this code was fine until your patch 1/3 changed it to\nhave a declaration after statement. Rather than creating a new patch\nto fix an earlier mistake in the same patch series, on this project,\nthe proper way to resolve such a problem is use \"git rebase -i\" to\nadjust patch 1/3 to not introduce the problem in the first place and\ndrop this patch, and then (re-)submit the patch series.\n\nAlso, your Signed-off-by: is missing (see Documentation/SubmittingPatches).\n"},{"id":"368315","messageId":"CAPig+cTyVu7maTXBLaeCK7V_42+QrDPUs57a3F_tdwRDMYtcaA@mail.gmail.com","threadId":"50376","inReplyTo":"01020168a8338127-d50bd8d1-c178-4f13-86b1-9a191f64ded0-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH 3/3] It's C not C++ so variable length array should not be used [-Werror=vla] :,).","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2019-02-01T09:02:00Z","receivedAt":"2019-02-01T09:02:14Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Feb 1, 2019 at 3:36 AM Shahzad Lone <shahzadlone@gmail.com> wrote:\n> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\n> @@ -197,9 +197,8 @@ static unsigned long write_large_blob_data(struct git_istream *st, struct hashfi\n>                                            const struct object_id *oid)\n>  {\n>         git_zstream stream;\n> -       const unsigned bufsize = 16384;\n> -       unsigned char ibuf[bufsize];\n> -       unsigned char obuf[bufsize];\n> +       unsigned char ibuf[16384];\n> +       unsigned char obuf[16384];\n\nReiterating my comment on patch 2/3, this code was fine until your\npatch 1/3 changed it declare a variable length array. Rather than\ncreating a new patch to fix an earlier mistake in the same patch\nseries, use \"git rebase -i\" to adjust patch 1/3 to not introduce the\nproblem in the first place and drop this patch, and then (re-)submit\nthe patch series.\n\nThanks.\n"},{"id":"368394","messageId":"01020168ab79f642-10a06c5b-c3f7-441e-86f8-bff5e41ac834-000000@eu-west-1.amazonses.com","threadId":"50376","inReplyTo":"01020168a8338064-b1c054c4-3e05-4825-b8dc-636d9c63dcfc-000000@eu-west-1.amazonses.com","subject":"[PATCH v2 [rebased]] [Enhancement] Improve internals / refactoring.","fromName":"Shahzad Lone","fromEmail":"shahzadlone@gmail.com","sentAt":"2019-02-01T23:52:03Z","receivedAt":"2019-02-01T23:52:07Z","isPatch":true,"sender":{"key":"shahzadlone@gmail.com","avatar":"https://avatars.githubusercontent.com/u/30120428?v=4"},"body":"Changed to ```consts``` and tried to save arithmetic cost where I could.\n\nSorry my coding OCD bothered me when I didn't see them being ```consts```.\n\nSigned-off-by: Shahzad Lone <shahzadlone@gmail.com>\n---\n builtin/diff.c           |  2 +-\n builtin/pack-objects.c   | 18 +++++++++---------\n builtin/pack-redundant.c |  4 ++--\n pack-revindex.c          | 11 +++++------\n 4 files changed, 17 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex f0393bba23a7d..84a362ff5625b 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -102,7 +102,7 @@ static int builtin_diff_blobs(struct rev_info *revs,\n \t\t\t      int argc, const char **argv,\n \t\t\t      struct object_array_entry **blob)\n {\n-\tunsigned mode = canon_mode(S_IFREG | 0644);\n+\tconst unsigned mode = canon_mode(S_IFREG | 0644);\n \n \tif (argc > 1)\n \t\tusage(builtin_diff_usage);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 0a70d046043ec..3017beb8236fa 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -197,8 +197,8 @@ static unsigned long write_large_blob_data(struct git_istream *st, struct hashfi\n \t\t\t\t\t   const struct object_id *oid)\n {\n \tgit_zstream stream;\n-\tunsigned char ibuf[1024 * 16];\n-\tunsigned char obuf[1024 * 16];\n+\tunsigned char ibuf[16384];\n+\tunsigned char obuf[16384];\n \tunsigned long olen = 0;\n \n \tgit_deflate_init(&stream, pack_compression_level);\n@@ -1901,10 +1901,10 @@ static int type_size_sort(const void *_a, const void *_b)\n {\n \tconst struct object_entry *a = *(struct object_entry **)_a;\n \tconst struct object_entry *b = *(struct object_entry **)_b;\n-\tenum object_type a_type = oe_type(a);\n-\tenum object_type b_type = oe_type(b);\n-\tunsigned long a_size = SIZE(a);\n-\tunsigned long b_size = SIZE(b);\n+\tconst enum object_type a_type = oe_type(a);\n+\tconst enum object_type b_type = oe_type(b);\n+\tconst unsigned long a_size = SIZE(a);\n+\tconst unsigned long b_size = SIZE(b);\n \n \tif (a_type > b_type)\n \t\treturn -1;\n@@ -1919,7 +1919,7 @@ static int type_size_sort(const void *_a, const void *_b)\n \tif (a->preferred_base < b->preferred_base)\n \t\treturn 1;\n \tif (use_delta_islands) {\n-\t\tint island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid);\n+\t\tconst int island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid);\n \t\tif (island_cmp)\n \t\t\treturn island_cmp;\n \t}\n@@ -2171,7 +2171,7 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)\n \tstruct object_entry *child = DELTA_CHILD(me);\n \tunsigned int m = n;\n \twhile (child) {\n-\t\tunsigned int c = check_delta_limit(child, n + 1);\n+\t\tconst unsigned int c = check_delta_limit(child, n + 1);\n \t\tif (m < c)\n \t\t\tm = c;\n \t\tchild = DELTA_SIBLING(child);\n@@ -2226,7 +2226,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n \t\twhile (window_memory_limit &&\n \t\t       mem_usage > window_memory_limit &&\n \t\t       count > 1) {\n-\t\t\tuint32_t tail = (idx + window - count) % window;\n+\t\t\tconst uint32_t tail = (idx + window - count) % window;\n \t\t\tmem_usage -= free_unpacked(array + tail);\n \t\t\tcount--;\n \t\t}\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex cf9a9aabd4eb2..11bc51456631e 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -166,7 +166,7 @@ static inline struct llist_item * llist_sorted_remove(struct llist *list, const\n \tl = (hint == NULL) ? list->front : hint;\n \tprev = NULL;\n \twhile (l) {\n-\t\tint cmp = oidcmp(l->oid, oid);\n+\t\tconst int cmp = oidcmp(l->oid, oid);\n \t\tif (cmp > 0) /* not in list, since sorted */\n \t\t\treturn prev;\n \t\tif (!cmp) { /* found */\n@@ -264,7 +264,7 @@ static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)\n \twhile (p1_off < p1->pack->num_objects * p1_step &&\n \t       p2_off < p2->pack->num_objects * p2_step)\n \t{\n-\t\tint cmp = hashcmp(p1_base + p1_off, p2_base + p2_off);\n+\t\tconst int cmp = hashcmp(p1_base + p1_off, p2_base + p2_off);\n \t\t/* cmp ~ p1 - p2 */\n \t\tif (cmp == 0) {\n \t\t\tp1_hint = llist_sorted_remove(p1->unique_objects,\ndiff --git a/pack-revindex.c b/pack-revindex.c\nindex 3c58784a5f4de..40651ec9fac2e 100644\n--- a/pack-revindex.c\n+++ b/pack-revindex.c\n@@ -119,7 +119,7 @@ static void sort_revindex(struct revindex_entry *entries, unsigned n, off_t max)\n  */\n static void create_pack_revindex(struct packed_git *p)\n {\n-\tunsigned num_ent = p->num_objects;\n+\tconst unsigned num_ent = p->num_objects;\n \tunsigned i;\n \tconst char *index = p->index_data;\n \tconst unsigned hashsz = the_hash_algo->rawsz;\n@@ -132,7 +132,7 @@ static void create_pack_revindex(struct packed_git *p)\n \t\t\t(uint32_t *)(index + 8 + p->num_objects * (hashsz + 4));\n \t\tconst uint32_t *off_64 = off_32 + p->num_objects;\n \t\tfor (i = 0; i < num_ent; i++) {\n-\t\t\tuint32_t off = ntohl(*off_32++);\n+\t\t\tconst uint32_t off = ntohl(*off_32++);\n \t\t\tif (!(off & 0x80000000)) {\n \t\t\t\tp->revindex[i].offset = off;\n \t\t\t} else {\n@@ -143,7 +143,7 @@ static void create_pack_revindex(struct packed_git *p)\n \t\t}\n \t} else {\n \t\tfor (i = 0; i < num_ent; i++) {\n-\t\t\tuint32_t hl = *((uint32_t *)(index + (hashsz + 4) * i));\n+\t\t\tconst uint32_t hl = *((uint32_t *)(index + (hashsz + 4) * i));\n \t\t\tp->revindex[i].offset = ntohl(hl);\n \t\t\tp->revindex[i].nr = i;\n \t\t}\n@@ -168,10 +168,10 @@ int find_revindex_position(struct packed_git *p, off_t ofs)\n {\n \tint lo = 0;\n \tint hi = p->num_objects + 1;\n-\tstruct revindex_entry *revindex = p->revindex;\n+\tconst struct revindex_entry *revindex = p->revindex;\n \n \tdo {\n-\t\tunsigned mi = lo + (hi - lo) / 2;\n+\t\tconst unsigned mi = lo + (hi - lo) / 2;\n \t\tif (revindex[mi].offset == ofs) {\n \t\t\treturn mi;\n \t\t} else if (ofs < revindex[mi].offset)\n@@ -187,7 +187,6 @@ int find_revindex_position(struct packed_git *p, off_t ofs)\n struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs)\n {\n \tint pos;\n-\n \tload_pack_revindex(p);\n \tpos = find_revindex_position(p, ofs);\n \n\n--\nhttps://github.com/git/git/pull/572\n"},{"id":"368398","messageId":"CAETBDP7jw_z_Nz7X-+jne7sYrJ7G92wWsB3S_ipf3XjJwxYxfw@mail.gmail.com","threadId":"50376","inReplyTo":"01020168ab79f642-10a06c5b-c3f7-441e-86f8-bff5e41ac834-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH v2 [rebased]] [Enhancement] Improve internals / refactoring.","fromName":"Brandon Richardson","fromEmail":"brandon1024.br@gmail.com","sentAt":"2019-02-02T03:09:29Z","receivedAt":"2019-02-02T03:09:45Z","isPatch":true,"sender":{"key":"brandon1024.br@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22732449?v=4"},"body":"Hi Shahzad,\n\nOn Fri, 1 Feb 2019 at 19:54, Shahzad Lone <shahzadlone@gmail.com> wrote:\n>         git_zstream stream;\n> -       unsigned char ibuf[1024 * 16];\n> -       unsigned char obuf[1024 * 16];\n> +       unsigned char ibuf[16384];\n> +       unsigned char obuf[16384];\n>         unsigned long olen = 0;\n\nThis change also brings very little value because most compilers will\nevaluate constant expressions such as this at compile time. A quick\ngoogle query on \"Constant Folding\" will tell you all about this.\n\nI love optimization as much as the next guy, but I also feel an argument can\nbe made for readability too. The former version is far easier to see that\nthe array will be 16KB in size, where 16384 is more difficult to visualize.\n"},{"id":"368420","messageId":"01020168b080030b-eb0a0634-f2b9-42ed-a3be-76995e7127eb-000000@eu-west-1.amazonses.com","threadId":"50376","inReplyTo":"01020168ab79f642-10a06c5b-c3f7-441e-86f8-bff5e41ac834-000000@eu-west-1.amazonses.com","subject":"[PATCH v3 [re-fixed] ] [Enhancement] Improve internals / refactoring.","fromName":"Shahzad Lone","fromEmail":"shahzadlone@gmail.com","sentAt":"2019-02-02T23:16:45Z","receivedAt":"2019-02-02T23:16:50Z","isPatch":true,"sender":{"key":"shahzadlone@gmail.com","avatar":"https://avatars.githubusercontent.com/u/30120428?v=4"},"body":"Changed to ```consts``` and tried to save arithmetic cost where I could.\n\nSorry my coding OCD bothered me when I didn't see them being ```consts```.\n\nSigned-off-by: Shahzad Lone <shahzadlone@gmail.com>\n---\n builtin/diff.c           |  2 +-\n builtin/pack-objects.c   | 14 +++++++-------\n builtin/pack-redundant.c |  4 ++--\n pack-revindex.c          | 10 +++++-----\n 4 files changed, 15 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex f0393bba23a7d..84a362ff5625b 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -102,7 +102,7 @@ static int builtin_diff_blobs(struct rev_info *revs,\n \t\t\t      int argc, const char **argv,\n \t\t\t      struct object_array_entry **blob)\n {\n-\tunsigned mode = canon_mode(S_IFREG | 0644);\n+\tconst unsigned mode = canon_mode(S_IFREG | 0644);\n \n \tif (argc > 1)\n \t\tusage(builtin_diff_usage);\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 0a70d046043ec..5c406ab4945f5 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -1901,10 +1901,10 @@ static int type_size_sort(const void *_a, const void *_b)\n {\n \tconst struct object_entry *a = *(struct object_entry **)_a;\n \tconst struct object_entry *b = *(struct object_entry **)_b;\n-\tenum object_type a_type = oe_type(a);\n-\tenum object_type b_type = oe_type(b);\n-\tunsigned long a_size = SIZE(a);\n-\tunsigned long b_size = SIZE(b);\n+\tconst enum object_type a_type = oe_type(a);\n+\tconst enum object_type b_type = oe_type(b);\n+\tconst unsigned long a_size = SIZE(a);\n+\tconst unsigned long b_size = SIZE(b);\n \n \tif (a_type > b_type)\n \t\treturn -1;\n@@ -1919,7 +1919,7 @@ static int type_size_sort(const void *_a, const void *_b)\n \tif (a->preferred_base < b->preferred_base)\n \t\treturn 1;\n \tif (use_delta_islands) {\n-\t\tint island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid);\n+\t\tconst int island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid);\n \t\tif (island_cmp)\n \t\t\treturn island_cmp;\n \t}\n@@ -2171,7 +2171,7 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)\n \tstruct object_entry *child = DELTA_CHILD(me);\n \tunsigned int m = n;\n \twhile (child) {\n-\t\tunsigned int c = check_delta_limit(child, n + 1);\n+\t\tconst unsigned int c = check_delta_limit(child, n + 1);\n \t\tif (m < c)\n \t\t\tm = c;\n \t\tchild = DELTA_SIBLING(child);\n@@ -2226,7 +2226,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,\n \t\twhile (window_memory_limit &&\n \t\t       mem_usage > window_memory_limit &&\n \t\t       count > 1) {\n-\t\t\tuint32_t tail = (idx + window - count) % window;\n+\t\t\tconst uint32_t tail = (idx + window - count) % window;\n \t\t\tmem_usage -= free_unpacked(array + tail);\n \t\t\tcount--;\n \t\t}\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex cf9a9aabd4eb2..11bc51456631e 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -166,7 +166,7 @@ static inline struct llist_item * llist_sorted_remove(struct llist *list, const\n \tl = (hint == NULL) ? list->front : hint;\n \tprev = NULL;\n \twhile (l) {\n-\t\tint cmp = oidcmp(l->oid, oid);\n+\t\tconst int cmp = oidcmp(l->oid, oid);\n \t\tif (cmp > 0) /* not in list, since sorted */\n \t\t\treturn prev;\n \t\tif (!cmp) { /* found */\n@@ -264,7 +264,7 @@ static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)\n \twhile (p1_off < p1->pack->num_objects * p1_step &&\n \t       p2_off < p2->pack->num_objects * p2_step)\n \t{\n-\t\tint cmp = hashcmp(p1_base + p1_off, p2_base + p2_off);\n+\t\tconst int cmp = hashcmp(p1_base + p1_off, p2_base + p2_off);\n \t\t/* cmp ~ p1 - p2 */\n \t\tif (cmp == 0) {\n \t\t\tp1_hint = llist_sorted_remove(p1->unique_objects,\ndiff --git a/pack-revindex.c b/pack-revindex.c\nindex 3c58784a5f4de..50891f77a26d6 100644\n--- a/pack-revindex.c\n+++ b/pack-revindex.c\n@@ -119,7 +119,7 @@ static void sort_revindex(struct revindex_entry *entries, unsigned n, off_t max)\n  */\n static void create_pack_revindex(struct packed_git *p)\n {\n-\tunsigned num_ent = p->num_objects;\n+\tconst unsigned num_ent = p->num_objects;\n \tunsigned i;\n \tconst char *index = p->index_data;\n \tconst unsigned hashsz = the_hash_algo->rawsz;\n@@ -132,7 +132,7 @@ static void create_pack_revindex(struct packed_git *p)\n \t\t\t(uint32_t *)(index + 8 + p->num_objects * (hashsz + 4));\n \t\tconst uint32_t *off_64 = off_32 + p->num_objects;\n \t\tfor (i = 0; i < num_ent; i++) {\n-\t\t\tuint32_t off = ntohl(*off_32++);\n+\t\t\tconst uint32_t off = ntohl(*off_32++);\n \t\t\tif (!(off & 0x80000000)) {\n \t\t\t\tp->revindex[i].offset = off;\n \t\t\t} else {\n@@ -143,7 +143,7 @@ static void create_pack_revindex(struct packed_git *p)\n \t\t}\n \t} else {\n \t\tfor (i = 0; i < num_ent; i++) {\n-\t\t\tuint32_t hl = *((uint32_t *)(index + (hashsz + 4) * i));\n+\t\t\tconst uint32_t hl = *((uint32_t *)(index + (hashsz + 4) * i));\n \t\t\tp->revindex[i].offset = ntohl(hl);\n \t\t\tp->revindex[i].nr = i;\n \t\t}\n@@ -168,10 +168,10 @@ int find_revindex_position(struct packed_git *p, off_t ofs)\n {\n \tint lo = 0;\n \tint hi = p->num_objects + 1;\n-\tstruct revindex_entry *revindex = p->revindex;\n+\tconst struct revindex_entry *revindex = p->revindex;\n \n \tdo {\n-\t\tunsigned mi = lo + (hi - lo) / 2;\n+\t\tconst unsigned mi = lo + (hi - lo) / 2;\n \t\tif (revindex[mi].offset == ofs) {\n \t\t\treturn mi;\n \t\t} else if (ofs < revindex[mi].offset)\n\n--\nhttps://github.com/git/git/pull/572\n"},{"id":"368462","messageId":"xmqqbm3rwi7t.fsf@gitster-ct.c.googlers.com","threadId":"50376","inReplyTo":"01020168b080030b-eb0a0634-f2b9-42ed-a3be-76995e7127eb-000000@eu-west-1.amazonses.com","subject":"Re: [PATCH v3 [re-fixed] ] [Enhancement] Improve internals / refactoring.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-02-04T17:56:22Z","receivedAt":"2019-02-04T17:56:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Shahzad Lone <shahzadlone@gmail.com> writes:\n\n> Subject: Re: [PATCH v3 [re-fixed] ] [Enhancement] Improve internals / refactoring.\n\nSince all patches are attempts by their authors to improve\nsomething, the above has a very low information density.  As all the\nchanges in this patch are about const-ness, it would probably be a\ngood idea to sneak that word into the title---that way, when placed\namong many changes, a reader would be able to still recognize what\nthis change is about in \"git shortlog --no-merges\" output.\n\nPerhaps\n\n        Subject: [PATCH v3] tighten constness\n\nor something?\n"}]}