Skip to content

Commit 409f049

Browse files
pks-tttaylorr
authored andcommitted
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent ef8ce8f commit 409f049

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

reftable/block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static int block_writer_register_restart(struct block_writer *w, int n,
6060
w->next += n;
6161

6262
strbuf_reset(&w->last_key);
63-
strbuf_addbuf(&w->last_key, key);
63+
strbuf_add(&w->last_key, key->buf, key->len);
6464
w->entries++;
6565
return 0;
6666
}

reftable/record.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ static void reftable_index_record_key(const void *r, struct strbuf *dest)
10311031
{
10321032
const struct reftable_index_record *rec = r;
10331033
strbuf_reset(dest);
1034-
strbuf_addbuf(dest, &rec->last_key);
1034+
strbuf_add(dest, rec->last_key.buf, rec->last_key.len);
10351035
}
10361036

10371037
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,
10411041
const struct reftable_index_record *src = src_rec;
10421042

10431043
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);
10451045
dst->offset = src->offset;
10461046

10471047
return 0;
@@ -1085,7 +1085,7 @@ static int reftable_index_record_decode(void *rec, struct strbuf key,
10851085
int n = 0;
10861086

10871087
strbuf_reset(&r->last_key);
1088-
strbuf_addbuf(&r->last_key, &key);
1088+
strbuf_add(&r->last_key, key.buf, key.len);
10891089

10901090
n = get_var_int(&r->offset, &in);
10911091
if (n < 0)

reftable/writer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static int writer_index_hash(struct reftable_writer *w, struct strbuf *hash)
225225
*key = empty;
226226

227227
strbuf_reset(&key->hash);
228-
strbuf_addbuf(&key->hash, hash);
228+
strbuf_add(&key->hash, hash->buf, hash->len);
229229
tree_insert(&w->obj_index_tree, key,
230230
&obj_index_tree_node_compare);
231231
} else {
@@ -256,7 +256,7 @@ static int writer_add_record(struct reftable_writer *w,
256256
}
257257

258258
strbuf_reset(&w->last_key);
259-
strbuf_addbuf(&w->last_key, &key);
259+
strbuf_add(&w->last_key, key.buf, key.len);
260260
if (!w->block_writer) {
261261
err = writer_reinit_block_writer(w, reftable_record_type(rec));
262262
if (err < 0)
@@ -778,7 +778,8 @@ static int writer_flush_nonempty_block(struct reftable_writer *w)
778778

779779
index_record.offset = w->next;
780780
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);
782783
w->index[w->index_len] = index_record;
783784
w->index_len++;
784785

0 commit comments

Comments
 (0)