From: Luca Heltai Date: Wed, 14 Jun 2017 16:07:03 +0000 (+0200) Subject: Improved code in Patterns::List X-Git-Tag: v9.0.0-rc1~1493^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=842a4e50d5cc94a69c8f5d13145dd65c84e8dd61;p=dealii.git Improved code in Patterns::List --- 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;