Skip to content

Commit

Permalink
Some template instantiation reductions
Browse files Browse the repository at this point in the history
  • Loading branch information
horenmar committed May 1, 2023
1 parent fe64c28 commit 10f0a58
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
18 changes: 10 additions & 8 deletions src/catch2/catch_test_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,18 @@ namespace Catch {
return std::any_of( m_filters.begin(), m_filters.end(), [&]( Filter const& f ){ return f.matches( testCase ); } );
}

TestSpec::Matches TestSpec::matchesByFilter( std::vector<TestCaseHandle> const& testCases, IConfig const& config ) const
{
Matches matches( m_filters.size() );
std::transform( m_filters.begin(), m_filters.end(), matches.begin(), [&]( Filter const& filter ){
TestSpec::Matches TestSpec::matchesByFilter( std::vector<TestCaseHandle> const& testCases, IConfig const& config ) const {
Matches matches;
matches.reserve( m_filters.size() );
for ( auto const& filter : m_filters ) {
std::vector<TestCaseHandle const*> currentMatches;
for( auto const& test : testCases )
if( isThrowSafe( test, config ) && filter.matches( test.getTestCaseInfo() ) )
for ( auto const& test : testCases )
if ( isThrowSafe( test, config ) &&
filter.matches( test.getTestCaseInfo() ) )
currentMatches.emplace_back( &test );
return FilterMatch{ extractFilterName(filter), currentMatches };
} );
matches.push_back(
FilterMatch{ extractFilterName( filter ), currentMatches } );
}
return matches;
}

Expand Down
6 changes: 3 additions & 3 deletions src/catch2/internal/catch_reporter_spec_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace Catch {
};

kvPair splitKVPair(StringRef kvString) {
auto splitPos = static_cast<size_t>( std::distance(
kvString.begin(),
std::find( kvString.begin(), kvString.end(), '=' ) ) );
auto splitPos = static_cast<size_t>(
std::find( kvString.begin(), kvString.end(), '=' ) -
kvString.begin() );

return { kvString.substr( 0, splitPos ),
kvString.substr( splitPos + 1, kvString.size() ) };
Expand Down
7 changes: 3 additions & 4 deletions src/catch2/internal/catch_string_manip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <catch2/internal/catch_string_manip.hpp>
#include <catch2/internal/catch_stringref.hpp>

#include <algorithm>
#include <ostream>
#include <cstring>
#include <cctype>
Expand All @@ -32,9 +31,9 @@ namespace Catch {
return s.find( infix ) != std::string::npos;
}
void toLowerInPlace( std::string& s ) {
std::transform( s.begin(), s.end(), s.begin(), []( char c ) {
return toLower( c );
} );
for ( char& c : s ) {
c = toLower( c );
}
}
std::string toLower( std::string const& s ) {
std::string lc = s;
Expand Down
2 changes: 1 addition & 1 deletion src/catch2/reporters/catch_reporter_compact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class AssertionPrinter {
return;

const auto itEnd = messages.cend();
const auto N = static_cast<std::size_t>(std::distance(itMessage, itEnd));
const auto N = static_cast<std::size_t>(itEnd - itMessage);

stream << colourImpl->guardColour( colour ) << " with "
<< pluralise( N, "message"_sr ) << ':';
Expand Down
3 changes: 1 addition & 2 deletions src/catch2/reporters/catch_reporter_tap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <catch2/reporters/catch_reporter_helpers.hpp>

#include <algorithm>
#include <iterator>
#include <ostream>

namespace Catch {
Expand Down Expand Up @@ -165,7 +164,7 @@ namespace Catch {

// using messages.end() directly (or auto) yields compilation error:
std::vector<MessageInfo>::const_iterator itEnd = messages.end();
const std::size_t N = static_cast<std::size_t>(std::distance(itMessage, itEnd));
const std::size_t N = static_cast<std::size_t>(itEnd - itMessage);

stream << colourImpl->guardColour( colour ) << " with "
<< pluralise( N, "message"_sr ) << ':';
Expand Down

0 comments on commit 10f0a58

Please sign in to comment.