From 6bec8fc1dbe9a54ffcb4b7d74bbf6992e8db873b Mon Sep 17 00:00:00 2001 From: mkrzewic Date: Sat, 12 Nov 2016 18:04:14 +0100 Subject: [PATCH] Simplify Tokenize(): nicer looking code = better code --- fairmq/FairMQChannel.cxx | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/fairmq/FairMQChannel.cxx b/fairmq/FairMQChannel.cxx index 505f243d..417f183c 100644 --- a/fairmq/FairMQChannel.cxx +++ b/fairmq/FairMQChannel.cxx @@ -791,19 +791,12 @@ void FairMQChannel::Tokenize(std::vector& output, using namespace std; size_t start = 0; size_t end = input.find_first_of(delimiters); - if (end == string::npos) - { - output.push_back(input.substr(start, input.length())); - } - else do + while (end != string::npos) { output.push_back(input.substr(start, end-start)); start = ++end; 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)); }