]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
optimise string comparison.. this time I've done it right.. sheesh shitty C++ name...
authorpippijn <pippijn@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 12 Jun 2008 21:25:46 +0000 (21:25 +0000)
committerpippijn <pippijn@e03df62e-2008-0410-955e-edbf42e46eb7>
Thu, 12 Jun 2008 21:25:46 +0000 (21:25 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9900 e03df62e-2008-0410-955e-edbf42e46eb7

include/hashcomp.h

index 6a6022a210c12fee732b8f146af5d3ebfb8e645b..24d0af60054728d1855843a5022e9af3c63dd73b 100644 (file)
@@ -14,6 +14,7 @@
 #ifndef _HASHCOMP_H_
 #define _HASHCOMP_H_
 
+#include <cstring>
 //#include "inspircd_config.h"
 //#include "socket.h"
 #include "hash_map.h"
@@ -620,6 +621,30 @@ inline bool operator!= (const std::string& leftval, const irc::string& rightval)
        return !(leftval.c_str() == rightval);
 }
 
+template<std::size_t N>
+static inline bool operator == (std::string const &lhs, char const (&rhs)[N])
+{
+       return lhs.length() == N - 1 && !std::memcmp(lhs.data(), rhs, N - 1);
+}
+
+template<std::size_t N>
+static inline bool operator != (std::string const &lhs, char const (&rhs)[N])
+{
+       return !(lhs == rhs);
+}
+
+template<std::size_t N>
+static inline bool operator == (irc::string const &lhs, char const (&rhs)[N])
+{
+       return lhs.length() == N - 1 && !std::memcmp(lhs.data(), rhs, N - 1);
+}
+
+template<std::size_t N>
+static inline bool operator != (irc::string const &lhs, char const (&rhs)[N])
+{
+       return !(lhs == rhs);
+}
+
 /** Assign an irc::string to a std::string.
  */
 inline std::string assign(const irc::string &other) { return other.c_str(); }