Merge branch 'ps/reftable-read-block-perffix'

Performance regression in not-yet-released code has been corrected.

* ps/reftable-read-block-perffix:
  reftable: fix perf regression when reading blocks of unwanted type
This commit is contained in:
Junio C Hamano
2025-05-19 16:02:48 -07:00
4 changed files with 19 additions and 17 deletions

View File

@@ -227,7 +227,8 @@ static int read_block(struct reftable_block_source *source,
int reftable_block_init(struct reftable_block *block,
struct reftable_block_source *source,
uint32_t offset, uint32_t header_size,
uint32_t table_block_size, uint32_t hash_size)
uint32_t table_block_size, uint32_t hash_size,
uint8_t want_type)
{
uint32_t guess_block_size = table_block_size ?
table_block_size : DEFAULT_BLOCK_SIZE;
@@ -247,6 +248,10 @@ int reftable_block_init(struct reftable_block *block,
err = REFTABLE_FORMAT_ERROR;
goto done;
}
if (want_type != REFTABLE_BLOCK_TYPE_ANY && block_type != want_type) {
err = 1;
goto done;
}
block_size = reftable_get_be24(block->block_data.data + header_size + 1);
if (block_size > guess_block_size) {