@@ -726,26 +726,28 @@ static bool PatternMatchesString(const std::string& name_str,
726726 return true ;
727727}
728728
729- static bool IsGlobPattern (const std::string& pattern) {
729+ namespace {
730+
731+ bool IsGlobPattern (const std::string& pattern) {
730732 return std::any_of (pattern.begin (), pattern.end (),
731733 [](const char c) { return c == ' ?' || c == ' *' ; });
732734}
733735
734- namespace {
735-
736736class UnitTestFilter {
737737 public:
738738 UnitTestFilter () = default ;
739739
740740 // Constructs a filter from a string of patterns separated by `:`.
741741 explicit UnitTestFilter (const std::string& filter) {
742742 // By design "" filter matches "" string.
743- SplitString (filter, ' :' , &glob_patterns_);
744- const auto exact_match_pattern_begin = std::partition (
745- glob_patterns_.begin (), glob_patterns_.end (), &IsGlobPattern);
746- exact_match_patterns_.insert (exact_match_pattern_begin,
747- glob_patterns_.end ());
748- glob_patterns_.erase (exact_match_pattern_begin, glob_patterns_.end ());
743+ std::vector<std::string> all_patterns;
744+ SplitString (filter, ' :' , &all_patterns);
745+ const auto exact_match_patterns_begin = std::partition (
746+ all_patterns.begin (), all_patterns.end (), &IsGlobPattern);
747+
748+ glob_patterns_.reserve (exact_match_patterns_begin - all_patterns.begin ());
749+ std::move (all_patterns.begin (), exact_match_patterns_begin, std::inserter (glob_patterns_, glob_patterns_.begin ()));
750+ std::move (exact_match_patterns_begin, all_patterns.end (), std::inserter (exact_match_patterns_, exact_match_patterns_.begin ()));
749751 }
750752
751753 // Returns true if and only if name matches at least one of the patterns in
0 commit comments