mirror of
https://github.com/git/git
synced 2024-10-30 04:01:21 +00:00
reftable/merged: refactor initialization of iterators
Refactor the initialization of the merged iterator to fit our code style better. This refactoring prepares the code for a refactoring of how records are being initialized. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
59f302ca5a
commit
62d3c8e8c8
1 changed files with 13 additions and 14 deletions
|
@ -19,24 +19,23 @@ license that can be found in the LICENSE file or at
|
|||
|
||||
static int merged_iter_init(struct merged_iter *mi)
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < mi->stack_len; i++) {
|
||||
struct reftable_record rec = reftable_new_record(mi->typ);
|
||||
int err = iterator_next(&mi->stack[i], &rec);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
}
|
||||
for (size_t i = 0; i < mi->stack_len; i++) {
|
||||
struct pq_entry e = {
|
||||
.rec = reftable_new_record(mi->typ),
|
||||
.index = i,
|
||||
};
|
||||
int err;
|
||||
|
||||
err = iterator_next(&mi->stack[i], &e.rec);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (err > 0) {
|
||||
reftable_iterator_destroy(&mi->stack[i]);
|
||||
reftable_record_release(&rec);
|
||||
} else {
|
||||
struct pq_entry e = {
|
||||
.rec = rec,
|
||||
.index = i,
|
||||
};
|
||||
merged_iter_pqueue_add(&mi->pq, &e);
|
||||
reftable_record_release(&e.rec);
|
||||
continue;
|
||||
}
|
||||
|
||||
merged_iter_pqueue_add(&mi->pq, &e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue