Skip to content

Commit 7a40a95

Browse files
chriscoolgitster
authored andcommitted
refs: use skip_prefix() in ref_is_hidden()
This is shorter, makes the logic a bit easier to follow, and is perhaps a bit faster too. The logic is to make the final decision only when "subject" is there, its early part matches "match", and the match is at the slash boundary (or the whole thing). Signed-off-by: Christian Couder <[email protected]> Reviewed-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 95d6787 commit 7a40a95

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

refs.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ int ref_is_hidden(const char *refname, const char *refname_full)
10661066
const char *match = hide_refs->items[i].string;
10671067
const char *subject;
10681068
int neg = 0;
1069-
int len;
1069+
const char *p;
10701070

10711071
if (*match == '!') {
10721072
neg = 1;
@@ -1081,10 +1081,9 @@ int ref_is_hidden(const char *refname, const char *refname_full)
10811081
}
10821082

10831083
/* refname can be NULL when namespaces are used. */
1084-
if (!subject || !starts_with(subject, match))
1085-
continue;
1086-
len = strlen(match);
1087-
if (!subject[len] || subject[len] == '/')
1084+
if (subject &&
1085+
skip_prefix(subject, match, &p) &&
1086+
(!*p || *p == '/'))
10881087
return !neg;
10891088
}
10901089
return 0;

0 commit comments

Comments
 (0)