Re: [PATCH 1/2] git wrapper: Make while loop more reader-friendly
- From
Mike Ralphson <mike.ralphson@gmail.com>
- Date
- Aug 26, 2008, 08:50 UTC
- Message-ID
- <e2b179460808260150p15b7da0ev913eced3709c2cd1@mail.gmail.com>
- In-Reply-To
- <alpine.DEB.1.00.0808252248150.24820@pacific.mpi-cbg.de.mpi-cbg.de>
2008/8/25 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
Show 32 quoted lines
>
> It is not a good practice to prefer performance over readability in
> something as performance uncritical as finding the trailing slash
> of argv[0].
>
> So avoid head-scratching by making the loop user-readable, and not
> hyper-performance-optimized.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>
> git.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/git.c b/git.c
> index a647741..2fd74c4 100644
> --- a/git.c
> +++ b/git.c
> @@ -427,9 +427,8 @@ int main(int argc, const char **argv)
> * name, and the dirname as the default exec_path
> * if we don't have anything better.
> */
> - do
> - --slash;
> - while (cmd <= slash && !is_dir_sep(*slash));
> + while (cmd <= slash && !is_dir_sep(*slash))
> + slash--;
> if (slash < cmd) {
> cmd = lookup_program_in_path(cmd);
> for (slash = (char *)cmd + strlen(cmd) - 1;
> --
> 1.6.0.211.ga840e.dirtyIsn't it more likely that this form was chosen to indicate that the loop body was expected to execute at least once, rather than zero or more times?
Mike