From: Vladimir Panteleev <git@thecybershadow.net>
To: git@vger.kernel.org
Cc: Vladimir Panteleev <git@thecybershadow.net>
Subject: [PATCH v2 3/4] show-ref: Optimize show_ref a bit
Date: Sat, 21 Jan 2017 01:08:20 +0000 [thread overview]
Message-ID: <20170121010821.25046-4-git@thecybershadow.net> (raw)
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
next prev parent reply other threads:[~2017-01-21 1:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-21 1:08 [PATCH v2] show-ref: Allow -d, --head to work with --verify Vladimir Panteleev
2017-01-21 1:08 ` [PATCH v2 1/4] show-ref: Allow " Vladimir Panteleev
2017-01-21 1:08 ` [PATCH v2 2/4] show-ref: Allow -d " Vladimir Panteleev
2017-01-21 1:08 ` Vladimir Panteleev [this message]
2017-01-22 22:47 ` [PATCH v2 3/4] show-ref: Optimize show_ref a bit Junio C Hamano
2017-01-22 22:55 ` Junio C Hamano
2017-01-21 1:08 ` [PATCH v2 4/4] show-ref: Inline show_one Vladimir Panteleev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170121010821.25046-4-git@thecybershadow.net \
--to=git@thecybershadow.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).