{"thread":{"id":"36022","subject":"[PATCH v2] skip_prefix:rewrite so that prefix is scanned once","startedAt":"2014-03-02T15:03:04Z","lastAt":"2014-03-02T18:57:26Z","messageCount":2,"participants":["Siddharth Goel","Eric Sunshine"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"235800","messageId":"1393772584-3716-1-git-send-email-siddharth98391@gmail.com","threadId":"36022","inReplyTo":null,"subject":"[PATCH v2] skip_prefix:rewrite so that prefix is scanned once","fromName":"Siddharth Goel","fromEmail":"siddharth98391@gmail.com","sentAt":"2014-03-02T15:03:04Z","receivedAt":"2014-03-02T15:03:04Z","isPatch":true,"sender":{"key":"siddharth98391@gmail.com","avatar":"https://gravatar.com/avatar/a951feb4fe81ca0581ee1719eb493b15bf8bb86107ae07510bd669811808ee19?d=mp&s=160"},"body":"Helped-by: Eric Sunshine <sunshine@sunshineco.com>\nSigned-off-by: Siddharth Goel <siddharth98391@gmail.com>\n---\nThanks a lot Eric for your valuable comments. Please let me know if there is \nanything else which needs to be modified in this patch.\n\n git-compat-util.h | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 614a5e9..550dce3 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -357,8 +357,11 @@ extern int suffixcmp(const char *str, const char *suffix);\n \n static inline const char *skip_prefix(const char *str, const char *prefix)\n {\n-\tsize_t len = strlen(prefix);\n-\treturn strncmp(str, prefix, len) ? NULL : str + len;\n+\twhile (*prefix != '\\0' && *str == *prefix) {\n+\t\tstr++;\n+\t\tprefix++;\n+\t}\n+\treturn (*prefix == '\\0' ? str : NULL);\n }\n \n #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)\n-- \n1.9.0.138.g2de3478.dirty\n"},{"id":"235805","messageId":"CAPig+cS9SXwF5ZGzPW1GGoWqxQhKXSyGuEv2yWKbtKXDR-7CAA@mail.gmail.com","threadId":"36022","inReplyTo":"1393772584-3716-1-git-send-email-siddharth98391@gmail.com","subject":"Re: [PATCH v2] skip_prefix:rewrite so that prefix is scanned once","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2014-03-02T18:57:26Z","receivedAt":"2014-03-02T18:57:26Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Mar 2, 2014 at 10:03 AM, Siddharth Goel\n<siddharth98391@gmail.com> wrote:\n> Helped-by: Eric Sunshine <sunshine@sunshineco.com>\n> Signed-off-by: Siddharth Goel <siddharth98391@gmail.com>\n> ---\n> Thanks a lot Eric for your valuable comments. Please let me know if there is\n> anything else which needs to be modified in this patch.\n\nOther than suggesting that you insert a space after the colon in the\nsubject, I don't have any further comments on this patch. That's\nprobably not a reason to resend, though.\n\nAs general commentary to any potential GSoC students reading this: do\nwhat you can to ease the review process. One way to do so is to supply\ncommentary below the \"---\" line (or in the cover letter) explaining\nwhat changed in the present patch compared with the previous attempt.\nBonus points for providing a reference to the previous version of the\nsubmission, like this [1].\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/243097\n\n>  git-compat-util.h | 7 +++++--\n>  1 file changed, 5 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index 614a5e9..550dce3 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -357,8 +357,11 @@ extern int suffixcmp(const char *str, const char *suffix);\n>\n>  static inline const char *skip_prefix(const char *str, const char *prefix)\n>  {\n> -       size_t len = strlen(prefix);\n> -       return strncmp(str, prefix, len) ? NULL : str + len;\n> +       while (*prefix != '\\0' && *str == *prefix) {\n> +               str++;\n> +               prefix++;\n> +       }\n> +       return (*prefix == '\\0' ? str : NULL);\n>  }\n>\n>  #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)\n> --\n> 1.9.0.138.g2de3478.dirty\n"}]}