Skip to content

Commit b66e006

Browse files
pks-tgitster
authored andcommitted
reftable/writer: simplify writing index records
When finishing the current section some index records might be written for the section to the table. The logic that adds these records to the writer duplicates what we already have in `writer_add_record()`, making this more complicated than it really has to be. Simplify the code by using `writer_add_record()` instead. While at it, drop the unneeded braces around a loop to make the code conform to our code style better. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9ebb2d7 commit b66e006

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

reftable/writer.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -412,26 +412,14 @@ static int writer_finish_section(struct reftable_writer *w)
412412
.idx = idx[i],
413413
},
414414
};
415-
if (block_writer_add(w->block_writer, &rec) == 0) {
416-
continue;
417-
}
418415

419-
err = writer_flush_block(w);
416+
err = writer_add_record(w, &rec);
420417
if (err < 0)
421418
return err;
422-
423-
writer_reinit_block_writer(w, BLOCK_TYPE_INDEX);
424-
425-
err = block_writer_add(w->block_writer, &rec);
426-
if (err != 0) {
427-
/* write into fresh block should always succeed
428-
*/
429-
abort();
430-
}
431419
}
432-
for (i = 0; i < idx_len; i++) {
420+
421+
for (i = 0; i < idx_len; i++)
433422
strbuf_release(&idx[i].last_key);
434-
}
435423
reftable_free(idx);
436424
}
437425

0 commit comments

Comments
 (0)