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>
This commit is contained in:
parent
257f3020f6
commit
698a68be7b
@ -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_error_routine(void (*routine)(const char *err, va_list params));
|
||||||
extern void set_warn_routine(void (*routine)(const char *warn, 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
|
#ifdef NO_MMAP
|
||||||
|
|
||||||
#ifndef PROT_READ
|
#ifndef PROT_READ
|
||||||
@ -396,15 +398,6 @@ static inline int sane_case(int x, int high)
|
|||||||
return x;
|
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)
|
static inline int strtoul_ui(char const *s, int base, unsigned int *result)
|
||||||
{
|
{
|
||||||
unsigned long ul;
|
unsigned long ul;
|
||||||
|
9
strbuf.c
9
strbuf.c
@ -1,5 +1,14 @@
|
|||||||
#include "cache.h"
|
#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
|
* 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
|
* buf is non NULL and ->buf is NUL terminated even for a freshly
|
||||||
|
Loading…
Reference in New Issue
Block a user