reftable: stop using `strbuf_addbuf()`

We're about to introduce our own `reftable_buf` type to replace `strbuf`. Get rid of the seldomly-used `strbuf_addbuf()` function such that we have to reimplement one less function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Taylor Blau <me@ttaylorr.com>

Patrick Steinhardt committed Oct 17, 2024 at 06:53 UTC 409f04995e6ede838576fb795cf45dc6f10ab508
3 files changed +8 -7
reftable/block.c
+1 -1
@@ -60,7 +60,7 @@ static int block_writer_register_restart(struct block_writer *w, int n,
60 w->next += n;
61
62 strbuf_reset(&w->last_key);
63 - strbuf_addbuf(&w->last_key, key);
63 + strbuf_add(&w->last_key, key->buf, key->len);
64 w->entries++;
65 return 0;
66 }
reftable/record.c
+3 -3
@@ -1031,7 +1031,7 @@ static void reftable_index_record_key(const void *r, struct strbuf *dest)
1031 {
1032 const struct reftable_index_record *rec = r;
1033 strbuf_reset(dest);
1034 - strbuf_addbuf(dest, &rec->last_key);
1034 + strbuf_add(dest, rec->last_key.buf, rec->last_key.len);
1035 }
1036
1037 static int reftable_index_record_copy_from(void *rec, const void *src_rec,
@@ -1041,7 +1041,7 @@ static int reftable_index_record_copy_from(void *rec, const void *src_rec,
1041 const struct reftable_index_record *src = src_rec;
1042
1043 strbuf_reset(&dst->last_key);
1044 - strbuf_addbuf(&dst->last_key, &src->last_key);
1044 + strbuf_add(&dst->last_key, src->last_key.buf, src->last_key.len);
1045 dst->offset = src->offset;
1046
1047 return 0;
@@ -1085,7 +1085,7 @@ static int reftable_index_record_decode(void *rec, struct strbuf key,
1085 int n = 0;
1086
1087 strbuf_reset(&r->last_key);
1088 - strbuf_addbuf(&r->last_key, &key);
1088 + strbuf_add(&r->last_key, key.buf, key.len);
1089
1090 n = get_var_int(&r->offset, &in);
1091 if (n < 0)
reftable/writer.c
+4 -3
@@ -225,7 +225,7 @@ static int writer_index_hash(struct reftable_writer *w, struct strbuf *hash)
225 *key = empty;
226
227 strbuf_reset(&key->hash);
228 - strbuf_addbuf(&key->hash, hash);
228 + strbuf_add(&key->hash, hash->buf, hash->len);
229 tree_insert(&w->obj_index_tree, key,
230 &obj_index_tree_node_compare);
231 } else {
@@ -256,7 +256,7 @@ static int writer_add_record(struct reftable_writer *w,
256 }
257
258 strbuf_reset(&w->last_key);
259 - strbuf_addbuf(&w->last_key, &key);
259 + strbuf_add(&w->last_key, key.buf, key.len);
260 if (!w->block_writer) {
261 err = writer_reinit_block_writer(w, reftable_record_type(rec));
262 if (err < 0)
@@ -778,7 +778,8 @@ static int writer_flush_nonempty_block(struct reftable_writer *w)
778
779 index_record.offset = w->next;
780 strbuf_reset(&index_record.last_key);
781 - strbuf_addbuf(&index_record.last_key, &w->block_writer->last_key);
781 + strbuf_add(&index_record.last_key, w->block_writer->last_key.buf,
782 + w->block_writer->last_key.len);
783 w->index[w->index_len] = index_record;
784 w->index_len++;
785