Skip to content

Commit

Permalink
skip_prefix(): scan prefix only once
Browse files Browse the repository at this point in the history
Signed-off-by: David Kastrup <dak@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
David Kastrup authored and Junio C Hamano committed Mar 3, 2014
1 parent 5f95c9f commit ba399c4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
do {
if (!*prefix)
return str;
} while (*str++ == *prefix++);
return NULL;
}

#if defined(NO_MMAP) || defined(USE_WIN32_MMAP)
Expand Down

0 comments on commit ba399c4

Please sign in to comment.