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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
598019769c
commit
116fb64e43
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user