summaryrefslogtreecommitdiff
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorDavid Kastrup <dak@gnu.org>2014-03-04 00:22:15 +0100
committerJunio C Hamano <gitster@pobox.com>2014-03-03 15:38:14 -0800
commitba399c46d9d3930871480ec24518b1541bfdbab3 (patch)
tree94cd8534b38da302f8701d5d6dd7b518d741b1cf /git-compat-util.h
parent5f95c9f850b19b368c43ae399cc831b17a26a5ac (diff)
downloadgit-ba399c46d9d3930871480ec24518b1541bfdbab3.tar.gz
skip_prefix(): scan prefix only oncedk/skip-prefix-scan-only-once
Signed-off-by: David Kastrup <dak@gnu.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h7
1 files changed, 5 insertions, 2 deletions
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)