[PATCH v3 02/10] commit-graph: stop using signed integers to count Bloom filters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <ps@xxxxxx>
---
 commit-graph.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/commit-graph.c b/commit-graph.c
index bd7b6f5338..3fc1273ba5 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1170,11 +1170,11 @@ struct write_commit_graph_context {
 	size_t total_bloom_filter_data_size;
 	const struct bloom_filter_settings *bloom_settings;
 
-	int count_bloom_filter_computed;
-	int count_bloom_filter_not_computed;
-	int count_bloom_filter_trunc_empty;
-	int count_bloom_filter_trunc_large;
-	int count_bloom_filter_upgraded;
+	unsigned count_bloom_filter_computed;
+	unsigned count_bloom_filter_not_computed;
+	unsigned count_bloom_filter_trunc_empty;
+	unsigned count_bloom_filter_trunc_large;
+	unsigned count_bloom_filter_upgraded;
 };
 
 static int write_graph_chunk_fanout(struct hashfile *f,
@@ -1779,16 +1779,16 @@ void ensure_generations_valid(struct repository *r,
 
 static void trace2_bloom_filter_write_statistics(struct write_commit_graph_context *ctx)
 {
-	trace2_data_intmax("commit-graph", ctx->r, "filter-computed",
-			   ctx->count_bloom_filter_computed);
-	trace2_data_intmax("commit-graph", ctx->r, "filter-not-computed",
-			   ctx->count_bloom_filter_not_computed);
-	trace2_data_intmax("commit-graph", ctx->r, "filter-trunc-empty",
-			   ctx->count_bloom_filter_trunc_empty);
-	trace2_data_intmax("commit-graph", ctx->r, "filter-trunc-large",
-			   ctx->count_bloom_filter_trunc_large);
-	trace2_data_intmax("commit-graph", ctx->r, "filter-upgraded",
-			   ctx->count_bloom_filter_upgraded);
+	trace2_data_uintmax("commit-graph", ctx->r, "filter-computed",
+			    ctx->count_bloom_filter_computed);
+	trace2_data_uintmax("commit-graph", ctx->r, "filter-not-computed",
+			    ctx->count_bloom_filter_not_computed);
+	trace2_data_uintmax("commit-graph", ctx->r, "filter-trunc-empty",
+			    ctx->count_bloom_filter_trunc_empty);
+	trace2_data_uintmax("commit-graph", ctx->r, "filter-trunc-large",
+			    ctx->count_bloom_filter_trunc_large);
+	trace2_data_uintmax("commit-graph", ctx->r, "filter-upgraded",
+			    ctx->count_bloom_filter_upgraded);
 }
 
 static void compute_bloom_filters(struct write_commit_graph_context *ctx)

-- 
2.51.0.rc0.215.g125493bb4a.dirty





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux