reftable/stack: refactor function to gather table sizes
Refactor the function that gathers table sizes to be more idiomatic. For one, use `REFTABLE_CALLOC_ARRAY()` instead of `reftable_calloc()`. Second, avoid using an integer to iterate through the tables in the reftable stack given that `stack_len` itself is using a `size_t`. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
891ee3b9db
commit
ed7d2f4770
@ -1305,14 +1305,15 @@ struct segment suggest_compaction_segment(uint64_t *sizes, size_t n,
|
|||||||
|
|
||||||
static uint64_t *stack_table_sizes_for_compaction(struct reftable_stack *st)
|
static uint64_t *stack_table_sizes_for_compaction(struct reftable_stack *st)
|
||||||
{
|
{
|
||||||
uint64_t *sizes =
|
|
||||||
reftable_calloc(st->merged->stack_len, sizeof(*sizes));
|
|
||||||
int version = (st->opts.hash_id == GIT_SHA1_FORMAT_ID) ? 1 : 2;
|
int version = (st->opts.hash_id == GIT_SHA1_FORMAT_ID) ? 1 : 2;
|
||||||
int overhead = header_size(version) - 1;
|
int overhead = header_size(version) - 1;
|
||||||
int i = 0;
|
uint64_t *sizes;
|
||||||
for (i = 0; i < st->merged->stack_len; i++) {
|
|
||||||
|
REFTABLE_CALLOC_ARRAY(sizes, st->merged->stack_len);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < st->merged->stack_len; i++)
|
||||||
sizes[i] = st->readers[i]->size - overhead;
|
sizes[i] = st->readers[i]->size - overhead;
|
||||||
}
|
|
||||||
return sizes;
|
return sizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user