diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-05-19 16:02:48 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-05-19 16:02:48 -0700 |
| commit | 90eedabbf7cd949f76875821e983bce4e5172d23 (patch) | |
| tree | 07251d09b9a706a2e898988a37af5d125b69a3f1 /reftable | |
| parent | 2b3303166bb294cae6a321a5875331f3cc9e2ef6 (diff) | |
| parent | 1970333644fad127c68046697b9b86fd8d7f28c2 (diff) | |
| download | git-90eedabbf7cd949f76875821e983bce4e5172d23.tar.xz | |
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
Diffstat (limited to 'reftable')
| -rw-r--r-- | reftable/block.c | 7 | ||||
| -rw-r--r-- | reftable/reftable-block.h | 3 | ||||
| -rw-r--r-- | reftable/table.c | 11 |
3 files changed, 9 insertions, 12 deletions
diff --git a/reftable/block.c b/reftable/block.c index 471faa1642..920b3f4486 100644 --- a/reftable/block.c +++ b/reftable/block.c @@ -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) { diff --git a/reftable/reftable-block.h b/reftable/reftable-block.h index 04c3b518c8..0b05a8f7e3 100644 --- a/reftable/reftable-block.h +++ b/reftable/reftable-block.h @@ -56,7 +56,8 @@ struct reftable_block { int reftable_block_init(struct reftable_block *b, 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); /* Release resources allocated by the block. */ void reftable_block_release(struct reftable_block *b); diff --git a/reftable/table.c b/reftable/table.c index ee83127615..56362df0ed 100644 --- a/reftable/table.c +++ b/reftable/table.c @@ -173,16 +173,7 @@ int table_init_block(struct reftable_table *t, struct reftable_block *block, return 1; err = reftable_block_init(block, &t->source, next_off, header_off, - t->block_size, hash_size(t->hash_id)); - if (err < 0) - goto done; - - if (want_typ != REFTABLE_BLOCK_TYPE_ANY && block->block_type != want_typ) { - err = 1; - goto done; - } - -done: + t->block_size, hash_size(t->hash_id), want_typ); if (err) reftable_block_release(block); return err; |
