Uninline prefixcmp()
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>
Junio C Hamano committed
Jan 3, 2008 at 01:23 UTC
698a68be7b0df6dd8d0880e0e2167cad8688a6ad
2 files changed
+11
-9
git-compat-util.h
+2
-9
@@ -122,6 +122,8 @@ extern void set_die_routine(void (*routine)(const char *err, va_list params) NOR
122
extern void set_error_routine(void (*routine)(const char *err, va_list params));
123
extern void set_warn_routine(void (*routine)(const char *warn, va_list params));
124
125
+extern int prefixcmp(const char *str, const char *prefix);
126
+
127
#ifdef NO_MMAP
128
129
#ifndef PROT_READ
@@ -396,15 +398,6 @@ static inline int sane_case(int x, int high)
398
return x;
399
}
400
399
-static inline int prefixcmp(const char *str, const char *prefix)
400
-{
401
- for (; ; str++, prefix++)
402
- if (!*prefix)
403
- return 0;
404
- else if (*str != *prefix)
405
- return (unsigned char)*prefix - (unsigned char)*str;
406
-}
407
-
401
static inline int strtoul_ui(char const *s, int base, unsigned int *result)
402
{
403
unsigned long ul;
strbuf.c
+9
@@ -1,5 +1,14 @@
1
#include "cache.h"
2
3
+int prefixcmp(const char *str, const char *prefix)
4
+{
5
+ for (; ; str++, prefix++)
6
+ if (!*prefix)
7
+ return 0;
8
+ else if (*str != *prefix)
9
+ return (unsigned char)*prefix - (unsigned char)*str;
10
+}
11
+
12
/*
13
* Used as the default ->buf value, so that people can always assume
14
* buf is non NULL and ->buf is NUL terminated even for a freshly