diff options
| author | Jeff King <peff@peff.net> | 2024-10-03 17:06:54 -0400 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-10-03 14:22:21 -0700 |
| commit | 2011bb4f34d773a7de2d64769ca9f508feba8089 (patch) | |
| tree | 167ea1dd2f768516be0329a0bf5210f2081a5af4 /graph.c | |
| parent | line-log: use diff_line_prefix() instead of custom helper (diff) | |
| download | git-2011bb4f34d773a7de2d64769ca9f508feba8089.tar.gz git-2011bb4f34d773a7de2d64769ca9f508feba8089.zip | |
diff: drop line_prefix_length field
The diff_options structure holds a line_prefix string and an associated
length. But the length is always just the strlen() of the NUL-terminated
string. Let's simplify the code by just storing the string pointer and
assuming it is NUL-terminated when we use it.
This will cause us to compute the string length in a few extra spots,
but I don't think any of these are particularly hot code paths.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'graph.c')
| -rw-r--r-- | graph.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -74,10 +74,7 @@ static void graph_show_line_prefix(const struct diff_options *diffopt) if (!diffopt || !diffopt->line_prefix) return; - fwrite(diffopt->line_prefix, - sizeof(char), - diffopt->line_prefix_length, - diffopt->file); + fputs(diffopt->line_prefix, diffopt->file); } static const char **column_colors; @@ -321,8 +318,7 @@ static struct strbuf *diff_output_prefix_callback(struct diff_options *opt, void strbuf_reset(&msgbuf); if (opt->line_prefix) - strbuf_add(&msgbuf, opt->line_prefix, - opt->line_prefix_length); + strbuf_addstr(&msgbuf, opt->line_prefix); if (graph) graph_padding_line(graph, &msgbuf); return &msgbuf; |
