]> git.ipfire.org Git - thirdparty/git.git/commit
diff: return line_prefix directly when possible
authorJeff King <peff@peff.net>
Thu, 3 Oct 2024 21:11:31 +0000 (17:11 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 Oct 2024 21:22:22 +0000 (14:22 -0700)
commit19752d9c912478b9eef0bd83c2cf6da98974f536
tree852c5fc788c671de00fded477b47a855000f2f9e
parent436728fe9d75d05fa2439f867ca2039012b86e69
diff: return line_prefix directly when possible

We may point our output_prefix callback to diff_output_prefix_callback()
in any of these cases:

  1. we have a user-provided line_prefix

  2. we have a graph prefix to show

  3. both (1) and (2)

The function combines the available elements into a strbuf and returns
its pointer.

In the case that we just have the line_prefix, though, there is no need
for the strbuf. We can return the string directly.

This is a minor optimization by itself, but also will allow us to clean
up some memory ownership issues on top.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
graph.c