]> git.ipfire.org Git - thirdparty/git.git/commit
trailer: change strbuf in-place in unfold_value()
authorRené Scharfe <l.s.r@web.de>
Fri, 15 May 2026 07:33:53 +0000 (09:33 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 16 May 2026 13:11:07 +0000 (22:11 +0900)
commit34a891a2d30865316be2628949d4f1b005f65662
tree3f9f66a294e6b68a04827215db9ba856540eabcc
parent94f057755b7941b321fd11fec1b2e3ca5313a4e0
trailer: change strbuf in-place in unfold_value()

Avoid an allocation by doing s/\n\s*/ /g (replacing NL and any following
whitespace with a SP) right in the strbuf instead of copying the result
to a temporary one and swapping them in the end.  We can safely do that
because the replacement is never longer than the original string.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
trailer.c