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 --- apply.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'apply.c') diff --git a/apply.c b/apply.c index 0e2caeab9..b8bd5a4be 100644 --- a/apply.c +++ b/apply.c @@ -2046,7 +2046,7 @@ static void prefix_one(struct apply_state *state, char **name) char *old_name = *name; if (!old_name) return; - *name = xstrdup(prefix_filename(state->prefix, state->prefix_length, *name)); + *name = xstrdup(prefix_filename(state->prefix, *name)); free(old_name); } @@ -4815,9 +4815,7 @@ int apply_all_patches(struct apply_state *state, read_stdin = 0; continue; } else if (0 < state->prefix_length) - arg = prefix_filename(state->prefix, - state->prefix_length, - arg); + arg = prefix_filename(state->prefix, arg); fd = open(arg, O_RDONLY); if (fd < 0) { -- cgit v1.2.1