diff options
| author | Martin Hořeňovský | 2021-12-26 22:10:20 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-12-28 00:20:55 +0100 |
| commit | 45577a1f4c84eca059453908220cbdc7e1d34f93 (patch) | |
| tree | fd0978d2ef6cc5a975d66d852d59de6cb9ca1812 /src/catch2/catch_test_spec.cpp | |
| parent | cbb6764fb1c22bbd283ea7af6a69d012c470ec58 (diff) | |
| download | catch3-45577a1f4c84eca059453908220cbdc7e1d34f93.tar.gz | |
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.
Diffstat (limited to 'src/catch2/catch_test_spec.cpp')
| -rw-r--r-- | src/catch2/catch_test_spec.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/catch2/catch_test_spec.cpp b/src/catch2/catch_test_spec.cpp index 4c59695d..a3235d43 100644 --- a/src/catch2/catch_test_spec.cpp +++ b/src/catch2/catch_test_spec.cpp @@ -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 { |