git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] refs: use skip_prefix() in ref_is_hidden()
@ 2017-07-21  9:57 Christian Couder
  2017-07-21 16:55 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Couder @ 2017-07-21  9:57 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Lukas Fleischer, Jeff King, Christian Couder

This saves one line, makes the code a bit easier to understand
and perhaps a bit faster too.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 refs.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/refs.c b/refs.c
index ba22f4acef..15cb36d426 100644
--- a/refs.c
+++ b/refs.c
@@ -1160,7 +1160,7 @@ int ref_is_hidden(const char *refname, const char *refname_full)
 		const char *match = hide_refs->items[i].string;
 		const char *subject;
 		int neg = 0;
-		int len;
+		const char *p;
 
 		if (*match == '!') {
 			neg = 1;
@@ -1175,10 +1175,9 @@ int ref_is_hidden(const char *refname, const char *refname_full)
 		}
 
 		/* refname can be NULL when namespaces are used. */
-		if (!subject || !starts_with(subject, match))
+		if (!subject || !skip_prefix(subject, match, &p))
 			continue;
-		len = strlen(match);
-		if (!subject[len] || subject[len] == '/')
+		if (!*p || *p == '/')
 			return !neg;
 	}
 	return 0;
-- 
2.14.0.rc0.26.g981adb928e.dirty


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-21 16:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-21  9:57 [PATCH] refs: use skip_prefix() in ref_is_hidden() Christian Couder
2017-07-21 16:55 ` Junio C Hamano

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).