From cf6ba58008b3700388222b3e75f07d5b0bfe8fdc Mon Sep 17 00:00:00 2001 From: pippijn Date: Thu, 12 Jun 2008 21:00:48 +0000 Subject: 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 --- include/inspircd.h | 20 ++++++++++++++++---- 1 file 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 inline long ConvToInt(const T &in) return atoi(tmp.str().c_str()); } +template +static inline bool operator == (std::basic_string const &lhs, char const (&rhs)[N]) +{ + return lhs.length() == N - 1 && !std::memcmp(lhs.data(), rhs, N - 1); +} + +template +static inline bool operator != (std::basic_string 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); -- cgit v1.2.3