From de8118e153c5e527263086605e437ccca5d4f1ef Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 18 Jun 2014 15:57:17 -0400 Subject: use skip_prefix to avoid repeated calculations In some cases, we use starts_with to check for a prefix, and then use an already-calculated prefix length to advance a pointer past the prefix. There are no magic numbers or duplicated strings here, but we can still make the code simpler and more obvious by using skip_prefix. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- http.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'http.c') diff --git a/http.c b/http.c index 2b4f6a357c..f04621e61d 100644 --- a/http.c +++ b/http.c @@ -1087,11 +1087,10 @@ static int update_url_from_redirect(struct strbuf *base, if (!strcmp(asked, got->buf)) return 0; - if (!starts_with(asked, base->buf)) + if (!skip_prefix(asked, base->buf, &tail)) die("BUG: update_url_from_redirect: %s is not a superset of %s", asked, base->buf); - tail = asked + base->len; tail_len = strlen(tail); if (got->len < tail_len || -- cgit v1.3-5-g9baa