diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-10-02 08:51:45 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-10-02 08:51:45 +0000 |
commit | bd0413a193f185d4d7a8b26fb19b6b997489e134 (patch) | |
tree | 815d2551df0105e6b953caad105fe23fa34b3bed | |
parent | 02fe4a30856a7bc931e680e8667ab9fa13149b15 (diff) |
More efficient modestacker
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5390 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/hashcomp.h | 2 | ||||
-rw-r--r-- | src/hashcomp.cpp | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h index dde123acb..1f6592093 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -131,7 +131,7 @@ namespace irc public: modestacker(bool add); void Push(char modeletter, const std::string ¶meter); - std::deque<std::string> GetStackedLine(); + int GetStackedLine(std::deque<std::string> &result); }; /** irc::tokenstream reads a string formatted as per RFC1459 and RFC2812. diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index d0a4ab104..8a4febb60 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -321,12 +321,12 @@ void irc::modestacker::Push(char modeletter, const std::string ¶meter) sequence.push_back(parameter); } -std::deque<std::string> irc::modestacker::GetStackedLine() +int irc::modestacker::GetStackedLine(std::deque<std::string> &result) { - std::deque<std::string> result; - result.push_back(""); + result.clear(); + result.push_back(adding ? "+" : "-"); - while (!sequence[0].empty() && (sequence.size() > 1)) + while (!sequence[0].empty() && (sequence.size() > 1) && (result.size() < MAXMODES+1)) { result[0] += *(sequence[0].begin()); result.push_back(sequence[1]); @@ -334,6 +334,6 @@ std::deque<std::string> irc::modestacker::GetStackedLine() sequence.erase(sequence.begin() + 1); } - return result; + return result.size(); } |