diff options
author | Adam <Adam@anope.org> | 2013-06-01 21:58:08 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-06-01 21:58:08 -0400 |
commit | b1ba1ec8aca4d086f4e8f1cd8573ba62e6096d07 (patch) | |
tree | c4b0d08241c7742c1727662cc6142337409f9048 /src/hashcomp.cpp | |
parent | 9956da18e3186591b5347e63081756390f4f35d5 (diff) |
Made sepstream::GetToken less recursiveish
Diffstat (limited to 'src/hashcomp.cpp')
-rw-r--r-- | src/hashcomp.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 7b3b906c2..1605546cb 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -104,16 +104,24 @@ bool sepstream::GetToken(Anope::string &token) return false; } - size_t p = this->pos; - while (p < this->tokens.length() && this->tokens[p] != this->sep) - ++p; - + if (!this->allow_empty) + { + this->pos = this->tokens.find_first_not_of(this->sep, this->pos); + if (this->pos == std::string::npos) + { + this->pos = this->tokens.length() + 1; + token.clear(); + return false; + } + } + + size_t p = this->tokens.find(this->sep, this->pos); + if (p == std::string::npos) + p = this->tokens.length(); + token = this->tokens.substr(this->pos, p - this->pos); this->pos = p + 1; - if (!this->allow_empty && token.empty()) - return GetToken(token); - return true; } |