Simplify Tokenize(): nicer looking code = better code

This commit is contained in:
mkrzewic 2016-11-12 18:04:14 +01:00
parent c2d7c49cf5
commit 6bec8fc1db

View File

@ -791,19 +791,12 @@ void FairMQChannel::Tokenize(std::vector<std::string>& output,
using namespace std; using namespace std;
size_t start = 0; size_t start = 0;
size_t end = input.find_first_of(delimiters); size_t end = input.find_first_of(delimiters);
if (end == string::npos) while (end != string::npos)
{
output.push_back(input.substr(start, input.length()));
}
else do
{ {
output.push_back(input.substr(start, end-start)); output.push_back(input.substr(start, end-start));
start = ++end; start = ++end;
end = input.find_first_of(delimiters, start); end = input.find_first_of(delimiters, start);
if (end == string::npos)
{
output.push_back(input.substr(start, input.length()));
} }
} while (end != string::npos); output.push_back(input.substr(start));
} }