From 116fb64e439d3744d0f244a51d7a6d714b7703ae Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 20 Mar 2017 21:22:28 -0400 Subject: prefix_filename: drop length parameter This function takes the prefix as a ptr/len pair, but in every caller the length is exactly strlen(ptr). Let's simplify the interface and just take the string. This saves callers specifying it (and in some cases handling a NULL prefix). In a handful of cases we had the length already without calling strlen, so this is technically slower. But it's not likely to matter (after all, if the prefix is non-empty we'll allocate and copy it into a buffer anyway). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff-no-index.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'diff-no-index.c') diff --git a/diff-no-index.c b/diff-no-index.c index df762fd0f7..5f7317ced9 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -236,7 +236,7 @@ static void fixup_paths(const char **path, struct strbuf *replacement) void diff_no_index(struct rev_info *revs, int argc, const char **argv) { - int i, prefixlen; + int i; const char *paths[2]; struct strbuf replacement = STRBUF_INIT; const char *prefix = revs->prefix; @@ -257,7 +257,6 @@ void diff_no_index(struct rev_info *revs, } } - prefixlen = prefix ? strlen(prefix) : 0; for (i = 0; i < 2; i++) { const char *p = argv[argc - 2 + i]; if (!strcmp(p, "-")) @@ -266,8 +265,8 @@ void diff_no_index(struct rev_info *revs, * path that is "-", spell it as "./-". */ p = file_from_standard_input; - else if (prefixlen) - p = xstrdup(prefix_filename(prefix, prefixlen, p)); + else if (prefix) + p = xstrdup(prefix_filename(prefix, p)); paths[i] = p; } -- cgit v1.2.3