Subject: Re: [PATCH 5/6] strbuf: remove unused istarts_with() function

From: Junio C Hamano <[email-masked]>
Date: Fri, 19 Nov 2021 11:14:32 -0800

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> It's arguably slightly odd to have a skip_prefix() and iskip_prefix(),
> but not both variants when it comes to starts_with(), but this is easy
> enough to resurrect should we ever need it, so let's drop it for now.

Let's not go there.  It is not easy at all to know that it used to
exist in the first place, which is more important part than knowing
that it is there and resurrect it.  We'd end up hearing from people
that the API is uneven, and seeing a patch that reinvents it, which
we have to review again.

Leaving an unused implementation is not without risk of going it
stale (imagine: when iskip_prefix() learns to honor locale aware
case insensitive comparison, istarts_with() that nobody uses may
be left behind without anybody noticing), so carrying an unused
function is not cost-free, but in this particular case, I think
keeping it is much better economy than removing it, even without
counting the cost of writing this response.

Thanks.

> Signed-off-by: Ævar Arnfjörð Bjarmason <[email-masked]>
> ---
>  git-compat-util.h | 1 -
>  strbuf.c          | 9 ---------
>  2 files changed, 10 deletions(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index d70ce142861..7117024a28b 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -512,7 +512,6 @@ report_fn get_warn_routine(void);
>  void set_die_is_recursing_routine(int (*routine)(void));
>  
>  int starts_with(const char *str, const char *prefix);
> -int istarts_with(const char *str, const char *prefix);
>  
>  /*
>   * If the string "str" begins with the string found in "prefix", return 1.
> diff --git a/strbuf.c b/strbuf.c
> index b22e9816559..1b52e3c8250 100644
> --- a/strbuf.c
> +++ b/strbuf.c
> @@ -12,15 +12,6 @@ int starts_with(const char *str, const char *prefix)
>  			return 0;
>  }
>  
> -int istarts_with(const char *str, const char *prefix)
> -{
> -	for (; ; str++, prefix++)
> -		if (!*prefix)
> -			return 1;
> -		else if (tolower(*str) != tolower(*prefix))
> -			return 0;
> -}
> -
>  int skip_to_optional_arg_default(const char *str, const char *prefix,
>  				 const char **arg, const char *def)
>  {