From 842a4e50d5cc94a69c8f5d13145dd65c84e8dd61 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Wed, 14 Jun 2017 18:07:03 +0200 Subject: [PATCH] Improved code in Patterns::List --- source/base/parameter_handler.cc | 34 ++++---------------------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/source/base/parameter_handler.cc b/source/base/parameter_handler.cc index 5e9b463f47..65625c0a25 100644 --- a/source/base/parameter_handler.cc +++ b/source/base/parameter_handler.cc @@ -602,42 +602,16 @@ namespace Patterns bool List::match (const std::string &test_string_list) const { - std::string tmp = test_string_list; - std::vector split_list; - - // first split the input list - while (tmp.length() != 0) - { - std::string name; - name = tmp; - - if (name.find(separator) != std::string::npos) - { - name.erase (name.find(separator), std::string::npos); - tmp.erase (0, tmp.find(separator)+separator.size()); - } - else - tmp = ""; - - while ((name.length() != 0) && - (std::isspace (name[0]))) - name.erase (0,1); - - while (std::isspace (name[name.length()-1])) - name.erase (name.length()-1, 1); - - split_list.push_back (name); - } + std::vector split_list = + Utilities::split_string_list(test_string_list, separator); if ((split_list.size() < min_elements) || (split_list.size() > max_elements)) return false; // check the different possibilities - for (std::vector::const_iterator - test_string = split_list.begin(); - test_string != split_list.end(); ++test_string) - if (pattern->match (*test_string) == false) + for (auto &string : split_list) + if (pattern->match (string) == false) return false; return true; -- 2.39.5