reftable/block: better grouping of functions

Function definitions and declaration of `struct block_reader` and
`struct block_iter` are somewhat mixed up, making it hard to see which
functions belong together. Rearrange them.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-04-08 14:16:36 +02:00
committed by Junio C Hamano
parent 42c7bdc36d
commit aac8c03cc4
2 changed files with 36 additions and 36 deletions

View File

@ -175,11 +175,6 @@ int block_writer_finish(struct block_writer *w)
return w->next;
}
uint8_t block_reader_type(struct block_reader *r)
{
return r->block.data[r->header_off];
}
int block_reader_init(struct block_reader *br, struct reftable_block *block,
uint32_t header_off, uint32_t table_block_size,
int hash_size)
@ -261,6 +256,31 @@ done:
return err;
}
uint8_t block_reader_type(struct block_reader *r)
{
return r->block.data[r->header_off];
}
int block_reader_first_key(struct block_reader *br, struct strbuf *key)
{
int off = br->header_off + 4, n;
struct string_view in = {
.buf = br->block.data + off,
.len = br->block_len - off,
};
uint8_t extra = 0;
strbuf_reset(key);
n = reftable_decode_key(key, &extra, in);
if (n < 0)
return n;
if (!key->len)
return REFTABLE_FORMAT_ERROR;
return 0;
}
static uint32_t block_reader_restart_offset(struct block_reader *br, int i)
{
return get_be24(br->restart_bytes + 3 * i);
@ -353,26 +373,6 @@ int block_iter_next(struct block_iter *it, struct reftable_record *rec)
return 0;
}
int block_reader_first_key(struct block_reader *br, struct strbuf *key)
{
int off = br->header_off + 4, n;
struct string_view in = {
.buf = br->block.data + off,
.len = br->block_len - off,
};
uint8_t extra = 0;
strbuf_reset(key);
n = reftable_decode_key(key, &extra, in);
if (n < 0)
return n;
if (!key->len)
return REFTABLE_FORMAT_ERROR;
return 0;
}
void block_iter_close(struct block_iter *it)
{
strbuf_release(&it->last_key);