summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 257f302)
raw | patch | inline | side by side (parent: 257f302)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 3 Jan 2008 09:23:12 +0000 (01:23 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 3 Jan 2008 09:23:12 +0000 (01:23 -0800) |
Now the routine is an open-coded loop that avoids an extra
strlen() in the previous implementation, it got a bit too big to
be inlined. Uninlining it makes code footprint smaller but the
result still retains the avoidance of strlen() cost.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
strlen() in the previous implementation, it got a bit too big to
be inlined. Uninlining it makes code footprint smaller but the
result still retains the avoidance of strlen() cost.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h | patch | blob | history | |
strbuf.c | patch | blob | history |
diff --git a/git-compat-util.h b/git-compat-util.h
index 7059cbdab7d79ecde6f0533776ba9d73c9b60a1b..b6ef5442b79bc8a071597c1b0ad5508a4ed55a33 100644 (file)
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -122,6 +122,8 @@ extern void set_die_routine(void (*routine)(const char *err, va_list params) NOR
extern void set_error_routine(void (*routine)(const char *err, va_list params));
extern void set_warn_routine(void (*routine)(const char *warn, va_list params));
+extern int prefixcmp(const char *str, const char *prefix);
+
#ifdef NO_MMAP
#ifndef PROT_READ
return x;
}
-static inline int prefixcmp(const char *str, const char *prefix)
-{
- for (; ; str++, prefix++)
- if (!*prefix)
- return 0;
- else if (*str != *prefix)
- return (unsigned char)*prefix - (unsigned char)*str;
-}
-
static inline int strtoul_ui(char const *s, int base, unsigned int *result)
{
unsigned long ul;
diff --git a/strbuf.c b/strbuf.c
index b9b194b3200e950cfdb3c696d92ece0657e9d344..5efcfc8860a82766b53a0d579fbdd0844d0f9b62 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
#include "cache.h"
+int prefixcmp(const char *str, const char *prefix)
+{
+ for (; ; str++, prefix++)
+ if (!*prefix)
+ return 0;
+ else if (*str != *prefix)
+ return (unsigned char)*prefix - (unsigned char)*str;
+}
+
/*
* Used as the default ->buf value, so that people can always assume
* buf is non NULL and ->buf is NUL terminated even for a freshly