fastcmp.h: mark fastcmp functions as pure
this might let the compiler optimize aways subsequent calls in some cases strcmp etc from glibc also does it prayin nothin changes the locale at runtime lmao
This commit is contained in:
parent
cfd34a6148
commit
1ce0c7d5af
2 changed files with 7 additions and 3 deletions
|
|
@ -199,6 +199,7 @@ typedef int32_t boolean;
|
|||
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) // >= GCC 3.1
|
||||
#define FUNCDEAD __attribute__ ((deprecated))
|
||||
#define FUNCINLINE __attribute__((always_inline))
|
||||
#define PUREFUNC __attribute__((pure))
|
||||
#define FUNCNONNULL __attribute__((nonnull))
|
||||
#endif
|
||||
|
||||
|
|
@ -264,6 +265,9 @@ typedef int32_t boolean;
|
|||
#ifndef ATTRNOINLINE
|
||||
#define ATTRNOINLINE
|
||||
#endif
|
||||
#ifndef PUREFUNC
|
||||
#define PUREFUNC
|
||||
#endif
|
||||
|
||||
/* Miscellaneous types that don't fit anywhere else (Can this be changed?) */
|
||||
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ extern "C" {
|
|||
|
||||
// returns false if s != c
|
||||
// returns true if s == c
|
||||
FUNCINLINE static ATTRINLINE boolean fasticmp(const char *s, const char *c)
|
||||
FUNCINLINE static ATTRINLINE PUREFUNC boolean fasticmp(const char *s, const char *c)
|
||||
{
|
||||
for (; *s && toupper(*s) == toupper(*c); s++, c++) ;
|
||||
return (*s == *c); // make sure both strings ended
|
||||
}
|
||||
|
||||
// case-sensitive of the above
|
||||
FUNCINLINE static ATTRINLINE boolean fastcmp(const char *s, const char *c)
|
||||
FUNCINLINE static ATTRINLINE PUREFUNC boolean fastcmp(const char *s, const char *c)
|
||||
{
|
||||
for (; *s && *s == *c; s++, c++) ;
|
||||
return (*s == *c); // make sure both strings ended
|
||||
|
|
@ -22,7 +22,7 @@ FUNCINLINE static ATTRINLINE boolean fastcmp(const char *s, const char *c)
|
|||
|
||||
// length-limited of the above
|
||||
// only true if both strings are at least l characters long AND match, case-sensitively!
|
||||
FUNCINLINE static ATTRINLINE boolean fastncmp(const char *s, const char *c, UINT16 l)
|
||||
FUNCINLINE static ATTRINLINE PUREFUNC boolean fastncmp(const char *s, const char *c, UINT16 l)
|
||||
{
|
||||
for (; *s && *s == *c && --l; s++, c++) ;
|
||||
return !l; // make sure you reached the end
|
||||
|
|
|
|||
Loading…
Reference in a new issue