git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] refs: use skip_prefix() in ref_is_hidden()

From
Christian Couder <christian.couder@gmail.com>
Date
Jul 21, 2017, 09:57 UTC
Message-ID
<20170721095757.28373-1-chriscool@tuxfamily.org>

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
Next: Junio C Hamano
Message 1 of 2 in “refs: use skip_prefix() in ref_is_hidden()”
  1. refs: use skip_prefix() in ref_is_hidden()Christian Couder, Jul 21, 2017
  2. Junio C HamanoJul 21, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.