summaryrefslogtreecommitdiff
path: root/src/hashcomp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hashcomp.cpp')
-rw-r--r--src/hashcomp.cpp30
1 files changed, 9 insertions, 21 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 8c34c8a56..2cb6fb972 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -451,7 +451,7 @@ int irc::modestacker::GetStackedLine(std::vector<std::string> &result, int max_l
irc::stringjoiner::stringjoiner(const std::string &seperator, const std::vector<std::string> &sequence, int begin, int end)
{
if (end < begin)
- throw "stringjoiner logic error, this causes problems.";
+ return; // nothing to do here
for (int v = begin; v < end; v++)
joined.append(sequence[v]).append(seperator);
@@ -461,7 +461,7 @@ irc::stringjoiner::stringjoiner(const std::string &seperator, const std::vector<
irc::stringjoiner::stringjoiner(const std::string &seperator, const std::deque<std::string> &sequence, int begin, int end)
{
if (end < begin)
- throw "stringjoiner logic error, this causes problems.";
+ return; // nothing to do here
for (int v = begin; v < end; v++)
joined.append(sequence[v]).append(seperator);
@@ -471,7 +471,7 @@ irc::stringjoiner::stringjoiner(const std::string &seperator, const std::deque<s
irc::stringjoiner::stringjoiner(const std::string &seperator, const char* const* sequence, int begin, int end)
{
if (end < begin)
- throw "stringjoiner logic error, this causes problems.";
+ return; // nothing to do here
for (int v = begin; v < end; v++)
joined.append(sequence[v]).append(seperator);
@@ -483,29 +483,17 @@ 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)
+irc::portparser::portparser(const std::string &source, bool allow_overlapped)
+ : sep(source), in_range(0), range_begin(0), range_end(0), overlapped(allow_overlapped)
{
- sep = new irc::commasepstream(source);
- overlap_set.clear();
-}
-
-irc::portparser::~portparser()
-{
- delete sep;
}
bool irc::portparser::Overlaps(long val)
{
- if (!overlapped)
+ if (overlapped)
return false;
- if (overlap_set.find(val) == overlap_set.end())
- {
- overlap_set[val] = true;
- return false;
- }
- else
- return true;
+ return (!overlap_set.insert(val).second);
}
long irc::portparser::GetToken()
@@ -533,14 +521,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;
}