summaryrefslogtreecommitdiff
path: root/src/hashcomp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hashcomp.cpp')
-rw-r--r--src/hashcomp.cpp95
1 files changed, 6 insertions, 89 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 32f74475f..2c7dca5b1 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -21,7 +21,6 @@
#include "inspircd.h"
-#include "hashcomp.h"
/******************************************************
*
@@ -152,15 +151,7 @@ unsigned const char rfc_case_sensitive_map[256] = {
250, 251, 252, 253, 254, 255, // 250-255
};
-size_t CoreExport irc::hash::operator()(const irc::string &s) const
-{
- register 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;
-}
-
-bool irc::StrHashComp::operator()(const std::string& s1, const std::string& s2) const
+bool irc::equals(const std::string& s1, const std::string& s2)
{
const unsigned char* n1 = (const unsigned char*)s1.c_str();
const unsigned char* n2 = (const unsigned char*)s2.c_str();
@@ -197,7 +188,7 @@ size_t irc::insensitive::operator()(const std::string &s) const
* only with *x replaced with national_case_insensitive_map[*x].
* This avoids a copy to use hash<const char*>
*/
- 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;
@@ -269,7 +260,7 @@ bool irc::tokenstream::GetToken(std::string &token)
/* This is the last parameter */
if (token[0] == ':' && !first)
{
- token = token.substr(1);
+ token.erase(token.begin());
if (!StreamEnd())
{
token += ' ';
@@ -281,14 +272,6 @@ bool irc::tokenstream::GetToken(std::string &token)
return true;
}
-bool irc::tokenstream::GetToken(irc::string &token)
-{
- std::string stdstring;
- bool returnval = GetToken(stdstring);
- token = assign(stdstring);
- return returnval;
-}
-
bool irc::tokenstream::GetToken(int &token)
{
std::string tok;
@@ -333,7 +316,7 @@ bool irc::sepstream::GetToken(std::string &token)
if (p == std::string::npos)
p = this->tokens.length();
- token = this->tokens.substr(this->pos, p - this->pos);
+ token.assign(tokens, this->pos, p - this->pos);
this->pos = p + 1;
return true;
@@ -349,71 +332,6 @@ bool irc::sepstream::StreamEnd()
return this->pos > this->tokens.length();
}
-irc::modestacker::modestacker(bool add) : adding(add)
-{
- sequence.clear();
- sequence.push_back("");
-}
-
-void irc::modestacker::Push(char modeletter, const std::string &parameter)
-{
- *(sequence.begin()) += modeletter;
- sequence.push_back(parameter);
-}
-
-void irc::modestacker::Push(char modeletter)
-{
- this->Push(modeletter,"");
-}
-
-void irc::modestacker::PushPlus()
-{
- this->Push('+',"");
-}
-
-void irc::modestacker::PushMinus()
-{
- this->Push('-',"");
-}
-
-int irc::modestacker::GetStackedLine(std::vector<std::string> &result, int max_line_size)
-{
- if (sequence.empty())
- {
- return 0;
- }
-
- unsigned int n = 0;
- int size = 1; /* Account for initial +/- char */
- int nextsize = 0;
- int start = result.size();
- std::string modeline = adding ? "+" : "-";
- result.push_back(modeline);
-
- if (sequence.size() > 1)
- nextsize = sequence[1].length() + 2;
-
- while (!sequence[0].empty() && (sequence.size() > 1) && (n < ServerInstance->Config->Limits.MaxModes) && ((size + nextsize) < max_line_size))
- {
- modeline += *(sequence[0].begin());
- if (!sequence[1].empty())
- {
- result.push_back(sequence[1]);
- size += nextsize; /* Account for mode character and whitespace */
- }
- sequence[0].erase(sequence[0].begin());
- sequence.erase(sequence.begin() + 1);
-
- if (sequence.size() > 1)
- nextsize = sequence[1].length() + 2;
-
- n++;
- }
- result[start] = modeline;
-
- return n;
-}
-
std::string irc::stringjoiner(const std::vector<std::string>& sequence, char separator)
{
std::string joined;
@@ -478,10 +396,9 @@ long irc::portparser::GetToken()
std::string::size_type dash = x.rfind('-');
if (dash != std::string::npos)
{
- std::string sbegin = x.substr(0, dash);
- std::string send = x.substr(dash+1, x.length());
+ std::string sbegin(x, 0, dash);
range_begin = atoi(sbegin.c_str());
- range_end = atoi(send.c_str());
+ range_end = atoi(x.c_str()+dash+1);
if ((range_begin > 0) && (range_end > 0) && (range_begin < 65536) && (range_end < 65536) && (range_begin < range_end))
{