]> git.ipfire.org Git - thirdparty/git.git/blobdiff - git-compat-util.h
skip_prefix(): scan prefix only once
[thirdparty/git.git] / git-compat-util.h
index cbd86c37f51c00679498107d1a05131c19afa36e..bca22ae54e7f6e48afec5683594bcd91a7812eee 100644 (file)
@@ -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)