X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fhashcomp.cpp;h=b320f3546fa6b5a7dd507774d2a52c4719ec0d5f;hb=ee641f3f229143940fbe359ac98863edfdf249ce;hp=a1e08bbf7850a867c72afaa30fbef88c705649b4;hpb=fd655fa93a00a5f2993adb7ef562b6dbab8aa87c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index a1e08bbf7..b320f3546 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -154,29 +154,6 @@ unsigned const char rfc_case_sensitive_map[256] = { 250, 251, 252, 253, 254, 255, // 250-255 }; -void std::tr1::strlower(char *n) -{ - if (n) - { - for (char* t = n; *t; t++) - *t = national_case_insensitive_map[(unsigned char)*t]; - } -} - -size_t std::tr1::insensitive::operator()(const std::string &s) const -{ - /* XXX: NO DATA COPIES! :) - * The hash function here is practically - * a copy of the one in STL's hash_fun.h, - * only with *x replaced with national_case_insensitive_map[*x]. - * This avoids a copy to use hash - */ - register 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; -} - size_t CoreExport irc::hash::operator()(const irc::string &s) const { register size_t t = 0; @@ -195,6 +172,20 @@ bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) return (national_case_insensitive_map[*n1] == national_case_insensitive_map[*n2]); } +size_t irc::insensitive::operator()(const std::string &s) const +{ + /* XXX: NO DATA COPIES! :) + * The hash function here is practically + * a copy of the one in STL's hash_fun.h, + * only with *x replaced with national_case_insensitive_map[*x]. + * This avoids a copy to use hash + */ + register 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; +} + /****************************************************** * * This is the implementation of our special irc::string @@ -254,10 +245,6 @@ irc::tokenstream::tokenstream(const std::string &source) : tokens(source), last_ n = tokens.begin(); } -irc::tokenstream::~tokenstream() -{ -} - bool irc::tokenstream::GetToken(std::string &token) { std::string::iterator lsp = last_starting_position; @@ -370,42 +357,6 @@ bool irc::sepstream::StreamEnd() return ((n + 1) == tokens.end()); } -irc::sepstream::~sepstream() -{ -} - -std::string irc::hex(const unsigned char *raw, size_t rawsz) -{ - if (!rawsz) - return ""; - - /* EWW! This used to be using sprintf, which is WAY inefficient. -Special */ - - const char *hex = "0123456789abcdef"; - static char hexbuf[MAXBUF]; - - size_t i, j; - for (i = 0, j = 0; j < rawsz; ++j) - { - hexbuf[i++] = hex[raw[j] / 16]; - hexbuf[i++] = hex[raw[j] % 16]; - } - hexbuf[i] = 0; - - return hexbuf; -} - -CoreExport const char* irc::Spacify(const char* n) -{ - static char x[MAXBUF]; - strlcpy(x,n,MAXBUF); - for (char* y = x; *y; y++) - if (*y == '_') - *y = ' '; - return x; -} - - irc::modestacker::modestacker(bool add) : adding(add) { sequence.clear(); @@ -471,37 +422,17 @@ int irc::modestacker::GetStackedLine(std::vector &result, int max_l return n; } -irc::stringjoiner::stringjoiner(const std::string &seperator, const std::vector &sequence, int begin, int end) -{ - if (end < begin) - return; // nothing to do here - - for (int v = begin; v < end; v++) - joined.append(sequence[v]).append(seperator); - joined.append(sequence[end]); -} - -irc::stringjoiner::stringjoiner(const std::string &seperator, const std::deque &sequence, int begin, int end) -{ - if (end < begin) - return; // nothing to do here - - for (int v = begin; v < end; v++) - joined.append(sequence[v]).append(seperator); - joined.append(sequence[end]); -} - -irc::stringjoiner::stringjoiner(const std::string &seperator, const char* const* sequence, int begin, int end) +irc::stringjoiner::stringjoiner(const std::string& seperator, const std::vector& sequence, unsigned int begin, unsigned int end) { if (end < begin) return; // nothing to do here - for (int v = begin; v < end; v++) + for (unsigned int v = begin; v < end; v++) joined.append(sequence[v]).append(seperator); joined.append(sequence[end]); } -std::string& irc::stringjoiner::GetJoined() +const std::string& irc::stringjoiner::GetJoined() const { return joined; }