From bb81e1a5f38b1d6487e53aa5ac69ca7ced9f6562 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 9 Mar 2006 15:41:25 +0000 Subject: Improved strhashcomp with no allocations git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3596 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/hashcomp.cpp | 19 +++++++++++-------- src/svn-rev.sh | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index e94813420..10e1f331e 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -76,18 +76,21 @@ size_t nspace::hash::operator()(const struct in_addr &a) const size_t nspace::hash::operator()(const string &s) const { - char a[MAXBUF]; - static struct hash strhash; - strlcpy(a,s.c_str(),MAXBUF); - strlower(a); - return strhash(a); + char a[MAXBUF]; + static struct hash strhash; + strlcpy(a,s.c_str(),MAXBUF); + strlower(a); + return strhash(a); } bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) const { - irc::string a = s1.c_str(); - irc::string b = s2.c_str(); - return (a == b); + char* n1 = (char*)s1.c_str(); + char* n2 = (char*)s2.c_str(); + for (; *n1 && *n2; n1++, n2++) + if (lowertab[*n1] != lowertab[*n2]) + return false; + return (lowertab[*n1] == lowertab[*n2]); } bool irc::InAddr_HashComp::operator()(const in_addr &s1, const in_addr &s2) const diff --git a/src/svn-rev.sh b/src/svn-rev.sh index 8acb32dfb..74ad7dc66 100755 --- a/src/svn-rev.sh +++ b/src/svn-rev.sh @@ -1 +1 @@ -echo 3593 +echo 3595 -- cgit v1.2.3