Skip to content

Commit 27a4184

Browse files
mhaggergitster
authored andcommitted
create_snapshot(): use xmemdupz() rather than a strbuf
It's lighter weight. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a2854f commit 27a4184

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

refs/packed-backend.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,7 @@ static struct snapshot *create_snapshot(struct packed_ref_store *refs)
620620

621621
/* If the file has a header line, process it: */
622622
if (snapshot->buf < snapshot->eof && *snapshot->buf == '#') {
623-
struct strbuf tmp = STRBUF_INIT;
624-
char *p, *eol;
623+
char *tmp, *p, *eol;
625624
struct string_list traits = STRING_LIST_INIT_NODUP;
626625

627626
eol = memchr(snapshot->buf, '\n',
@@ -631,9 +630,9 @@ static struct snapshot *create_snapshot(struct packed_ref_store *refs)
631630
snapshot->buf,
632631
snapshot->eof - snapshot->buf);
633632

634-
strbuf_add(&tmp, snapshot->buf, eol - snapshot->buf);
633+
tmp = xmemdupz(snapshot->buf, eol - snapshot->buf);
635634

636-
if (!skip_prefix(tmp.buf, "# pack-refs with:", (const char **)&p))
635+
if (!skip_prefix(tmp, "# pack-refs with:", (const char **)&p))
637636
die_invalid_line(refs->path,
638637
snapshot->buf,
639638
snapshot->eof - snapshot->buf);
@@ -653,7 +652,7 @@ static struct snapshot *create_snapshot(struct packed_ref_store *refs)
653652
snapshot->start = eol + 1;
654653

655654
string_list_clear(&traits, 0);
656-
strbuf_release(&tmp);
655+
free(tmp);
657656
}
658657

659658
verify_buffer_safe(snapshot);

0 commit comments

Comments
 (0)