Tweak hash generation to make it faster

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5545 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2006-10-26 23:26:52 +00:00
parent 3bd571b8bb
commit 02e8724bbd

View File

@ -87,9 +87,9 @@ size_t nspace::hash<string>::operator()(const string &s) const
* This avoids a copy to use hash<const char*> * This avoids a copy to use hash<const char*>
*/ */
register size_t t = 0; register size_t t = 0;
for (std::string::const_iterator x = s.begin(); x != s.end(); x++) /* ++x not x++, so we don't hash the \0 */ for (std::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */
t = 5 * t + lowermap[(unsigned char)*x]; t = 5 * t + lowermap[(unsigned char)*x];
return size_t(t); return t;
} }
bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) const bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) const