X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fhashcomp.cpp;h=e0347421b29d01fb89e7cedd13d89aacde04fb74;hb=a5d110282a864fd2e91b51ce360a977cd0643657;hp=3a478bb20acb3de50f24abf9e80f591d7c504dde;hpb=03a8a981f16543b555172a3d426feac858d96576;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 3a478bb20..e0347421b 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -127,15 +127,12 @@ void nspace::strlower(char *n) } } -#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED) - size_t nspace::hash_compare >::operator()(const std::string &s) const +#ifdef HASHMAP_DEPRECATED + size_t CoreExport nspace::insensitive::operator()(const std::string &s) const #else - #ifdef HASHMAP_DEPRECATED - size_t CoreExport nspace::insensitive::operator()(const std::string &s) const - #else - size_t nspace::hash::operator()(const std::string &s) const - #endif + size_t nspace::hash::operator()(const std::string &s) const #endif + { /* XXX: NO DATA COPIES! :) * The hash function here is practically @@ -143,20 +140,16 @@ void nspace::strlower(char *n) * only with *x replaced with national_case_insensitive_map[*x]. * This avoids a copy to use hash */ - register size_t t = 0; + size_t t = 0; for (std::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */ t = 5 * t + national_case_insensitive_map[(unsigned char)*x]; return t; } -#if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED) - size_t nspace::hash_compare >::operator()(const irc::string &s) const -#else - size_t CoreExport irc::hash::operator()(const irc::string &s) const -#endif +size_t CoreExport irc::hash::operator()(const irc::string &s) const { - register size_t t = 0; + size_t t = 0; for (irc::string::const_iterator x = s.begin(); x != s.end(); ++x) /* ++x not x++, as its faster */ t = 5 * t + national_case_insensitive_map[(unsigned char)*x]; return t; @@ -333,7 +326,7 @@ bool irc::sepstream::GetToken(std::string &token) n++; } - token = ""; + token.clear(); return false; } @@ -483,19 +476,14 @@ std::string& irc::stringjoiner::GetJoined() return joined; } -irc::portparser::portparser(const std::string &source, bool allow_overlapped) : in_range(0), range_begin(0), range_end(0), overlapped(allow_overlapped) -{ - sep = new irc::commasepstream(source); -} - -irc::portparser::~portparser() +irc::portparser::portparser(const std::string &source, bool allow_overlapped) + : sep(source), in_range(0), range_begin(0), range_end(0), overlapped(allow_overlapped) { - delete sep; } bool irc::portparser::Overlaps(long val) { - if (!overlapped) + if (overlapped) return false; return (!overlap_set.insert(val).second); @@ -526,14 +514,14 @@ long irc::portparser::GetToken() } std::string x; - sep->GetToken(x); + sep.GetToken(x); if (x.empty()) return 0; while (Overlaps(atoi(x.c_str()))) { - if (!sep->GetToken(x)) + if (!sep.GetToken(x)) return 0; }