git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Siddharth Goel <siddharth98391@gmail.com>
Cc: Git List <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] git-compat-util.h:rewrite skip_prefix() as loop
Date: Sun, 2 Mar 2014 00:00:22 -0500	[thread overview]
Message-ID: <CAPig+cRDHb9usJW2zC20zXXM_9KxuEQ+=dkFmghp9JiVPcL1_w@mail.gmail.com> (raw)
In-Reply-To: <1393680724-19983-1-git-send-email-siddharth98391@gmail.com>

Thanks for the submission. Minor comments below to give you a taste of
what it's like to contribute to this project...

On Sat, Mar 1, 2014 at 8:32 AM, Siddharth Goel <siddharth98391@gmail.com> wrote:
> Rewrote skip_prefix() function so that prefix is scanned once.

Good description. In this project, use imperative tone, so say
"Rewrite skip_prefix()..." as you did in the subject. In fact, this
description is short enough and conveys sufficient information that it
could just be placed in the subject as the entire commit message.

    Subject: skip_prefix: rewrite so that prefix is scanned once

> Signed-off-by: Siddharth Goel <siddharth98391@gmail.com>
> ---
>  git-compat-util.h | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 614a5e9..550dce3 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -357,8 +357,11 @@ extern int suffixcmp(const char *str, const char *suffix);
>
>  static inline const char *skip_prefix(const char *str, const char *prefix)
>  {
> -       size_t len = strlen(prefix);
> -       return strncmp(str, prefix, len) ? NULL : str + len;
> +       while (*prefix != '\0' && *str == *prefix) {
> +               str++;
> +               prefix++;
> +       }
> +       return (*prefix == '\0' ? str : NULL);
>  }
>
>  #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)
> --
> 1.9.0.138.g2de3478.dirty

      parent reply	other threads:[~2014-03-02  5:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-01 13:32 [PATCH] git-compat-util.h:rewrite skip_prefix() as loop Siddharth Goel
2014-03-02  3:22 ` Siddharth Goel
2014-03-02  5:02   ` Eric Sunshine
2014-03-02  5:00 ` Eric Sunshine [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPig+cRDHb9usJW2zC20zXXM_9KxuEQ+=dkFmghp9JiVPcL1_w@mail.gmail.com' \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=siddharth98391@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).