mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
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
@@ -246,9 +246,11 @@ char *absolute_pathdup(const char *path)
|
||||
return strbuf_detach(&sb, NULL);
|
||||
}
|
||||
|
||||
const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
|
||||
const char *prefix_filename(const char *pfx, const char *arg)
|
||||
{
|
||||
static struct strbuf path = STRBUF_INIT;
|
||||
size_t pfx_len = pfx ? strlen(pfx) : 0;
|
||||
|
||||
#ifndef GIT_WINDOWS_NATIVE
|
||||
if (!pfx_len || is_absolute_path(arg))
|
||||
return arg;
|
||||
|
||||
Reference in New Issue
Block a user