mirror of
https://github.com/git/git
synced 2024-11-05 01:58:18 +00:00
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>
This commit is contained in:
parent
436728fe9d
commit
19752d9c91
1 changed files with 3 additions and 0 deletions
3
graph.c
3
graph.c
|
@ -316,6 +316,9 @@ static const char *diff_output_prefix_callback(struct diff_options *opt, void *d
|
|||
|
||||
assert(opt);
|
||||
|
||||
if (!graph)
|
||||
return opt->line_prefix;
|
||||
|
||||
strbuf_reset(&msgbuf);
|
||||
if (opt->line_prefix)
|
||||
strbuf_addstr(&msgbuf, opt->line_prefix);
|
||||
|
|
Loading…
Reference in a new issue