ls-refs: reuse buffer when sending refs
commitf54b9f21cab23209697d9985c16a7bf4ee7b4241
authorPatrick Steinhardt <ps@pks.im>
Wed, 25 Aug 2021 13:49:51 +0000 (25 15:49 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Aug 2021 22:55:29 +0000 (25 15:55 -0700)
tree5268bfcf9f3eaf809f31f45293e3d610c4ec9f88
parent225bc32a989d7a22fa6addafd4ce7dcd04675dbf
ls-refs: reuse buffer when sending refs

In the initial reference advertisement, the Git server will first
announce all of its references to the client. The logic is handled in
`send_ref()`, which will allocate a new buffer for each refline it is
about to send. This is quite wasteful: instead of allocating a new
buffer each time, we can just reuse a buffer.

Improve this by passing in a buffer via the `ls_refs_data` struct which
is then reused on each reference.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
ls-refs.c