From: David Kastrup Date: Mon, 3 Mar 2014 23:22:15 +0000 (+0100) Subject: skip_prefix(): scan prefix only once X-Git-Tag: v2.0.0-rc0~79^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/ba399c46d9d3930871480ec24518b1541bfdbab3?hp=--cc skip_prefix(): scan prefix only once Signed-off-by: David Kastrup Signed-off-by: Junio C Hamano --- ba399c46d9d3930871480ec24518b1541bfdbab3 diff --git a/git-compat-util.h b/git-compat-util.h index cbd86c37f5..bca22ae54e 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; + do { + if (!*prefix) + return str; + } while (*str++ == *prefix++); + return NULL; } #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)