diff mbox series

[02/10] reftable/stack: inline `stack_compact_range_stats()`

Message ID 3c0cf2bf46f4106d7c0b30c863946262639b2351.1724080006.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series reftable: fix reload with active iterators | expand

Commit Message

Patrick Steinhardt Aug. 19, 2024, 3:39 p.m. UTC
The only difference between `stack_compact_range_stats()` and
`stack_compact_range()` is that the former updates stats on failure,
whereas the latter doesn't. There are no callers anymore that do not
want their stats updated though, making the indirection unnecessary.

Inline the stat updates into `stack_compact_range()`.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 reftable/stack.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

Comments

Karthik Nayak Aug. 22, 2024, 8:23 a.m. UTC | #1
Patrick Steinhardt <ps@pks.im> writes:

> The only difference between `stack_compact_range_stats()` and
> `stack_compact_range()` is that the former updates stats on failure,
> whereas the latter doesn't. There are no callers anymore that do not
> want their stats updated though, making the indirection unnecessary.
>
> Inline the stat updates into `stack_compact_range()`.
>

This also ensures that we don't have users who end up using
`stack_compact_range()` because they didn't know about
`stack_compact_range_stats()`. Which was the case before, I think, I
remember one of the compaction function calling `stack_compact_range()`
directly. I see it is no longer the case though. Nice.

[snip]
diff mbox series

Patch

diff --git a/reftable/stack.c b/reftable/stack.c
index d3a95d2f1d..891ea971b7 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -1328,17 +1328,9 @@  static int stack_compact_range(struct reftable_stack *st,
 	strbuf_release(&table_name);
 	free_names(names);
 
-	return err;
-}
-
-static int stack_compact_range_stats(struct reftable_stack *st,
-				     size_t first, size_t last,
-				     struct reftable_log_expiry_config *config,
-				     unsigned int flags)
-{
-	int err = stack_compact_range(st, first, last, config, flags);
 	if (err == REFTABLE_LOCK_ERROR)
 		st->stats.failures++;
+
 	return err;
 }
 
@@ -1346,7 +1338,7 @@  int reftable_stack_compact_all(struct reftable_stack *st,
 			       struct reftable_log_expiry_config *config)
 {
 	size_t last = st->merged->readers_len ? st->merged->readers_len - 1 : 0;
-	return stack_compact_range_stats(st, 0, last, config, 0);
+	return stack_compact_range(st, 0, last, config, 0);
 }
 
 static int segment_size(struct segment *s)
@@ -1452,8 +1444,8 @@  int reftable_stack_auto_compact(struct reftable_stack *st)
 					   st->opts.auto_compaction_factor);
 	reftable_free(sizes);
 	if (segment_size(&seg) > 0)
-		return stack_compact_range_stats(st, seg.start, seg.end - 1,
-						 NULL, STACK_COMPACT_RANGE_BEST_EFFORT);
+		return stack_compact_range(st, seg.start, seg.end - 1,
+					   NULL, STACK_COMPACT_RANGE_BEST_EFFORT);
 
 	return 0;
 }