merge-ort: make path_messages a strmap to a string_list

This allows us once again to get away with less data copying.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2022-06-18 00:20:55 +00:00
committed by Junio C Hamano
parent 6debb7527b
commit 2715e8a931
3 changed files with 22 additions and 41 deletions

27
diff.c
View File

@ -3362,23 +3362,23 @@ struct userdiff_driver *get_textconv(struct repository *r,
return userdiff_get_textconv(r, one->driver);
}
static struct strbuf *additional_headers(struct diff_options *o,
const char *path)
static struct string_list *additional_headers(struct diff_options *o,
const char *path)
{
if (!o->additional_path_headers)
return NULL;
return strmap_get(o->additional_path_headers, path);
}
static void add_formatted_headers(struct strbuf *msg,
struct strbuf *more_headers,
static void add_formatted_header(struct strbuf *msg,
const char *header,
const char *line_prefix,
const char *meta,
const char *reset)
{
char *next, *newline;
const char *next, *newline;
for (next = more_headers->buf; *next; next = newline) {
for (next = header; *next; next = newline) {
newline = strchrnul(next, '\n');
strbuf_addf(msg, "%s%s%.*s%s\n", line_prefix, meta,
(int)(newline - next), next, reset);
@ -3387,6 +3387,19 @@ static void add_formatted_headers(struct strbuf *msg,
}
}
static void add_formatted_headers(struct strbuf *msg,
struct string_list *more_headers,
const char *line_prefix,
const char *meta,
const char *reset)
{
int i;
for (i = 0; i < more_headers->nr; i++)
add_formatted_header(msg, more_headers->items[i].string,
line_prefix, meta, reset);
}
static void builtin_diff(const char *name_a,
const char *name_b,
struct diff_filespec *one,
@ -4314,7 +4327,7 @@ static void fill_metainfo(struct strbuf *msg,
const char *set = diff_get_color(use_color, DIFF_METAINFO);
const char *reset = diff_get_color(use_color, DIFF_RESET);
const char *line_prefix = diff_line_prefix(o);
struct strbuf *more_headers = NULL;
struct string_list *more_headers = NULL;
*must_show_header = 1;
strbuf_init(msg, PATH_MAX * 2 + 300);