diff options
author | pippijn <pippijn@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-06-12 21:00:48 +0000 |
---|---|---|
committer | pippijn <pippijn@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-06-12 21:00:48 +0000 |
commit | cf6ba58008b3700388222b3e75f07d5b0bfe8fdc (patch) | |
tree | 15adb2c7e9ff12fc1d68c9d5fc1cd9d0419c12e4 /include | |
parent | 1519698640ed3fb389b87bb9272f523f40745260 (diff) |
optimise string-to-literal comparison while we are at it
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9896 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r-- | include/inspircd.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index e1048f114..6832b805f 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -15,8 +15,8 @@ #define __INSPIRCD_H__ #ifndef WIN32 -#define DllExport -#define CoreExport +#define DllExport +#define CoreExport #define printf_c printf #else #include "inspircd_win32wrapper.h" @@ -148,6 +148,18 @@ template<typename T> inline long ConvToInt(const T &in) return atoi(tmp.str().c_str()); } +template<typename CharT, typename TraitsT, std::size_t N> +static inline bool operator == (std::basic_string<CharT, TraitsT> const &lhs, char const (&rhs)[N]) +{ + return lhs.length() == N - 1 && !std::memcmp(lhs.data(), rhs, N - 1); +} + +template<typename CharT, typename TraitsT, std::size_t N> +static inline bool operator != (std::basic_string<CharT, TraitsT> const &lhs, char const (&rhs)[N]) +{ + return !(lhs == rhs); +} + /** Template function to convert integer to char, storing result in *res and * also returning the pointer to res. Based on Stuart Lowe's C/C++ Pages. * @param T input value @@ -424,7 +436,7 @@ class CoreExport InspIRCd : public classbase /** LogManager handles logging. */ LogManager *Logs; - + /** ModuleManager contains everything related to loading/unloading * modules. */ @@ -603,7 +615,7 @@ class CoreExport InspIRCd : public classbase */ void SignalHandler(int signal); - /** Sets the signal recieved + /** Sets the signal recieved * @param signal the signal recieved */ static void SetSignal(int signal); |