diff options
author | erorcun <erayorcunus@gmail.com> | 2019-11-09 16:06:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-09 16:06:20 +0100 |
commit | 0df15bb73dbdf352f92bc522c7b5c102f1e33ba5 (patch) | |
tree | 73c9bf00f83b91d7862f28296640860fa16291ab /src/core/General.h | |
parent | Fix link to config.h in readme (diff) | |
parent | Implemented faststrcmp, faststricmp, strcasecmp (diff) | |
download | re3-0df15bb73dbdf352f92bc522c7b5c102f1e33ba5.tar re3-0df15bb73dbdf352f92bc522c7b5c102f1e33ba5.tar.gz re3-0df15bb73dbdf352f92bc522c7b5c102f1e33ba5.tar.bz2 re3-0df15bb73dbdf352f92bc522c7b5c102f1e33ba5.tar.lz re3-0df15bb73dbdf352f92bc522c7b5c102f1e33ba5.tar.xz re3-0df15bb73dbdf352f92bc522c7b5c102f1e33ba5.tar.zst re3-0df15bb73dbdf352f92bc522c7b5c102f1e33ba5.zip |
Diffstat (limited to 'src/core/General.h')
-rw-r--r-- | src/core/General.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/core/General.h b/src/core/General.h index d73cf36f..a7b240c2 100644 --- a/src/core/General.h +++ b/src/core/General.h @@ -104,6 +104,29 @@ public: return (int)floorf(angle / DEGTORAD(45.0f)); } + // Unlike usual string comparison functions, these don't care about greater or lesser + static bool faststrcmp(const char *str1, const char *str2) + { + for (; *str1; str1++, str2++) { + if (*str1 != *str2) + return true; + } + return *str2 != '\0'; + } + + static bool faststricmp(const char *str1, const char *str2) + { + for (; *str1; str1++, str2++) { +#if MUCH_SLOWER + if (toupper(*str1) != toupper(*str2)) +#else + if (__ascii_toupper(*str1) != __ascii_toupper(*str2)) +#endif + return true; + } + return *str2 != '\0'; + } + // not too sure about all these... static uint16 GetRandomNumber(void) { return myrand() & MYRAND_MAX; } |