]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
optimise string-to-literal comparison while we are at it
authorpippijn <pippijn@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 12 Jun 2008 21:00:48 +0000 (21:00 +0000)
committerpippijn <pippijn@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 12 Jun 2008 21:00:48 +0000 (21:00 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9896 e03df62e-2008-0410-955e-edbf42e46eb7

include/inspircd.h

index e1048f1148ab58cf07b4950038b9db0907527d43..6832b805f49b5a9a0a2aa3509fc2d005e6e6d1d7 100644 (file)
@@ -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);