diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-10 19:15:42 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-10 19:15:42 +0000 |
commit | 782bbf7622cc383881f9acad232fb6dda7d55ab5 (patch) | |
tree | 870b06fa3ab4ebcc54f721ddd9cd4b781cc4cf56 | |
parent | 78dc9813021c9caf05fc47c08fc0827b4e6c8465 (diff) |
Much faster hash<string> for case-insensitive hashing, combined copy and lowercase operation
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4852 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/hashcomp.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 6606884c9..bf90eaeb8 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -87,10 +87,15 @@ size_t nspace::hash<insp_inaddr>::operator()(const insp_inaddr &a) const size_t nspace::hash<string>::operator()(const string &s) const { - char a[MAXBUF]; + char a[s.length()]; + size_t t = 0; static struct hash<const char *> strhash; - strlcpy(a,s.c_str(),MAXBUF); - strlower(a); + + for (const char* x = s.c_str(); *x; x++, t++) /* Faster to do it this way than */ + a[t] = lowermap[(unsigned char)*x]; /* Seperate strlcpy and strlower */ + + a[t] = 0; + return strhash(a); } |