[PATCH v2 3/4] show-ref: Optimize show_ref a bit
- From
Vladimir Panteleev <git@thecybershadow.net>
- Date
- Jan 21, 2017, 01:08 UTC
- Message-ID
- <20170121010821.25046-4-git@thecybershadow.net>
- In-Reply-To
- <20170121010821.25046-1-git@thecybershadow.net>
The inner `if (verify)' check was not being used before the preceding commit, as show_ref was never being called from a code path where verify was non-zero.
Adding a `!verify' check to the outer if skips an unnecessary string comparison when verify is non-zero, and show_ref is already called with a reference exactly matching pattern.
Signed-off-by: Vladimir Panteleev <git@thecybershadow.net> --- builtin/show-ref.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/builtin/show-ref.c b/builtin/show-ref.c index bcdc1a95e..3cf344d47 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -43,7 +43,7 @@ static int show_ref(const char *refname, const struct object_id *oid, if (!match) return 0; } - if (pattern) { + if (pattern && !verify) { int reflen = strlen(refname); const char **p = pattern, *m; while ((m = *p++) != NULL) { @@ -54,9 +54,6 @@ static int show_ref(const char *refname, const struct object_id *oid, continue; if (len == reflen) goto match; - /* "--verify" requires an exact match */ - if (verify) - continue; if (refname[reflen - len - 1] == '/') goto match; }
-- 2.11.0