Re: [PATCH v2 11/18] maintenance: auto-size incremental-repack batch
From: Đoàn Trần Công Danh <hidden>
Date: 2020-08-05 19:56:20
On 2020-07-30 15:02:32-0400, Derrick Stolee [off-list ref] wrote:
On 7/30/2020 12:57 PM, Derrick Stolee wrote:quoted
On 7/29/2020 6:23 PM, Emily Shaffer wrote:quoted
On Thu, Jul 23, 2020 at 05:56:33PM +0000, Derrick Stolee via GitGitGadget wrote:quoted
diff --git a/builtin/gc.c b/builtin/gc.c index eb4b01c104..889d97afe7 100644 --- a/builtin/gc.c +++ b/builtin/gc.c@@ -1021,19 +1021,65 @@ static int multi_pack_index_expire(void) return result; } +#define TWO_GIGABYTES (2147483647)[jonathan tan] This would be easier to understand if it was expressed with bitshift, e.g. 1 << 31This is actually ((1 << 31) - 1) because "unsigned long" is 32-bits on Windows. But it's better to not use magic numbers and instead use operations like this.Nevermind. This breaks the build on 32-bit machines (even adding a few "L" characters). I'll replace my magic decimal number with a magic hexadecimal number.
Would it be better if we use this C99 feature instead: #define TWO_GIGABYTES INT32_MAX But it seems like it's available everywhere, except (maybe) Windows. (judging from UINT32_MAX's usage) -- Danh