diff options
| author | Junio C Hamano <gitster@pobox.com> | 2024-02-26 18:10:24 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-02-26 18:10:24 -0800 |
| commit | 9f67cbd0a7725857d219da6720fc9a5acfda2960 (patch) | |
| tree | f7566b4db8e2f5d362d3464965e4a324d8d8516f /reftable/reader.c | |
| parent | 274400998b0a2da64d20e9fa95b288bf1403459c (diff) | |
| parent | c68ca7abd30b22404ce59d5133566729c07ffe8f (diff) | |
| download | git-9f67cbd0a7725857d219da6720fc9a5acfda2960.tar.xz | |
Merge branch 'ps/reftable-iteration-perf'
The code to iterate over refs with the reftable backend has seen
some optimization.
* ps/reftable-iteration-perf:
reftable/reader: add comments to `table_iter_next()`
reftable/record: don't try to reallocate ref record name
reftable/block: swap buffers instead of copying
reftable/pq: allocation-less comparison of entry keys
reftable/merged: skip comparison for records of the same subiter
reftable/merged: allocation-less dropping of shadowed records
reftable/record: introduce function to compare records by key
Diffstat (limited to 'reftable/reader.c')
| -rw-r--r-- | reftable/reader.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/reftable/reader.c b/reftable/reader.c index 2663b03938..b113daab77 100644 --- a/reftable/reader.c +++ b/reftable/reader.c @@ -357,24 +357,32 @@ static int table_iter_next(struct table_iter *ti, struct reftable_record *rec) while (1) { struct table_iter next = TABLE_ITER_INIT; - int err = 0; - if (ti->is_finished) { + int err; + + if (ti->is_finished) return 1; - } + /* + * Check whether the current block still has more records. If + * so, return it. If the iterator returns positive then the + * current block has been exhausted. + */ err = table_iter_next_in_block(ti, rec); - if (err <= 0) { + if (err <= 0) return err; - } + /* + * Otherwise, we need to continue to the next block in the + * table and retry. If there are no more blocks then the + * iterator is drained. + */ err = table_iter_next_block(&next, ti); - if (err != 0) { - ti->is_finished = 1; - } table_iter_block_done(ti); - if (err != 0) { + if (err) { + ti->is_finished = 1; return err; } + table_iter_copy_from(ti, &next); block_iter_close(&next.bi); } |
