Skip to content

Commit c448978

Browse files
pks-tgitster
authored andcommitted
commit-graph: stop using signed integers to count Bloom filters
When writing a new commit graph we have a couple of counters that provide statistics around what kind of Bloom filters we have or have not written. These counters naturally count from zero and are only ever incremented, but they use a signed integer as type regardless. Refactor those fields to be unsigned instead. Using an unsigned type makes it explicit to the reader that they never have to worry about negative values and thus makes the code easier to understand. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 10159fe commit c448978

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

commit-graph.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,11 +1171,11 @@ struct write_commit_graph_context {
11711171
size_t total_bloom_filter_data_size;
11721172
const struct bloom_filter_settings *bloom_settings;
11731173

1174-
int count_bloom_filter_computed;
1175-
int count_bloom_filter_not_computed;
1176-
int count_bloom_filter_trunc_empty;
1177-
int count_bloom_filter_trunc_large;
1178-
int count_bloom_filter_upgraded;
1174+
unsigned count_bloom_filter_computed;
1175+
unsigned count_bloom_filter_not_computed;
1176+
unsigned count_bloom_filter_trunc_empty;
1177+
unsigned count_bloom_filter_trunc_large;
1178+
unsigned count_bloom_filter_upgraded;
11791179
};
11801180

11811181
static int write_graph_chunk_fanout(struct hashfile *f,
@@ -1780,16 +1780,16 @@ void ensure_generations_valid(struct repository *r,
17801780

17811781
static void trace2_bloom_filter_write_statistics(struct write_commit_graph_context *ctx)
17821782
{
1783-
trace2_data_intmax("commit-graph", ctx->r, "filter-computed",
1784-
ctx->count_bloom_filter_computed);
1785-
trace2_data_intmax("commit-graph", ctx->r, "filter-not-computed",
1786-
ctx->count_bloom_filter_not_computed);
1787-
trace2_data_intmax("commit-graph", ctx->r, "filter-trunc-empty",
1788-
ctx->count_bloom_filter_trunc_empty);
1789-
trace2_data_intmax("commit-graph", ctx->r, "filter-trunc-large",
1790-
ctx->count_bloom_filter_trunc_large);
1791-
trace2_data_intmax("commit-graph", ctx->r, "filter-upgraded",
1792-
ctx->count_bloom_filter_upgraded);
1783+
trace2_data_uintmax("commit-graph", ctx->r, "filter-computed",
1784+
ctx->count_bloom_filter_computed);
1785+
trace2_data_uintmax("commit-graph", ctx->r, "filter-not-computed",
1786+
ctx->count_bloom_filter_not_computed);
1787+
trace2_data_uintmax("commit-graph", ctx->r, "filter-trunc-empty",
1788+
ctx->count_bloom_filter_trunc_empty);
1789+
trace2_data_uintmax("commit-graph", ctx->r, "filter-trunc-large",
1790+
ctx->count_bloom_filter_trunc_large);
1791+
trace2_data_uintmax("commit-graph", ctx->r, "filter-upgraded",
1792+
ctx->count_bloom_filter_upgraded);
17931793
}
17941794

17951795
static void compute_bloom_filters(struct write_commit_graph_context *ctx)

0 commit comments

Comments
 (0)