forked from catchorg/Catch2
Refactor implementation of case-insensitivity in tags
By not materializing the lower cased tags ahead of time, we save allocations at the cost of worsened performance when comparing two tags. Since there are rarely many tags, and commonly they are not compared even if present, this is almost always a win. The new implementation also improves the robustness of the code responsible for handling tags in a case-insensitive manner.
This commit is contained in:
@@ -38,15 +38,13 @@ namespace Catch {
|
||||
|
||||
TestSpec::TagPattern::TagPattern( std::string const& tag, std::string const& filterString )
|
||||
: Pattern( filterString )
|
||||
, m_tag( toLower( tag ) )
|
||||
, m_tag( tag )
|
||||
{}
|
||||
|
||||
bool TestSpec::TagPattern::matches( TestCaseInfo const& testCase ) const {
|
||||
return std::find_if(begin(testCase.tags),
|
||||
end(testCase.tags),
|
||||
[&](Tag const& tag) {
|
||||
return tag.lowerCased == m_tag;
|
||||
}) != end(testCase.tags);
|
||||
return std::find( begin( testCase.tags ),
|
||||
end( testCase.tags ),
|
||||
Tag( m_tag ) ) != end( testCase.tags );
|
||||
}
|
||||
|
||||
bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const {
|
||||
|
||||
Reference in New Issue
Block a user