diff options
Diffstat (limited to 'src/hashcomp.cpp')
-rw-r--r-- | src/hashcomp.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 4eb416406..f1d0f0678 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -170,6 +170,25 @@ bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) return (national_case_insensitive_map[*n1] == national_case_insensitive_map[*n2]); } +bool irc::insensitive_swo::operator()(const std::string& a, const std::string& b) const +{ + const unsigned char* charmap = national_case_insensitive_map; + std::string::size_type asize = a.size(); + std::string::size_type bsize = b.size(); + std::string::size_type maxsize = std::min(asize, bsize); + + for (std::string::size_type i = 0; i < maxsize; i++) + { + unsigned char A = charmap[(unsigned char)a[i]]; + unsigned char B = charmap[(unsigned char)b[i]]; + if (A > B) + return false; + else if (A < B) + return true; + } + return (asize < bsize); +} + size_t irc::insensitive::operator()(const std::string &s) const { /* XXX: NO DATA COPIES! :) |