diff --git a/src/catch2/reporters/catch_reporter_combined_tu.cpp b/src/catch2/reporters/catch_reporter_combined_tu.cpp index f6a650eb..b0e1f10f 100644 --- a/src/catch2/reporters/catch_reporter_combined_tu.cpp +++ b/src/catch2/reporters/catch_reporter_combined_tu.cpp @@ -10,13 +10,14 @@ * of Catch2 has its own combined TU like this. */ +#include #include #include #include -#include -#include + #include #include +#include namespace Catch { @@ -52,18 +53,26 @@ namespace Catch { return min >= 0 && duration >= min; } - std::string serializeFilters( std::vector const& container ) { - ReusableStringStream oss; - bool first = true; - for ( auto&& filter : container ) { - if ( !first ) - oss << ' '; - else - first = false; - - oss << filter; + std::string serializeFilters( std::vector const& filters ) { + // We add a ' ' separator between each filter + size_t serialized_size = filters.size() - 1; + for (auto const& filter : filters) { + serialized_size += filter.size(); } - return oss.str(); + + std::string serialized; + serialized.reserve(serialized_size); + bool first = true; + + for (auto const& filter : filters) { + if (!first) { + serialized.push_back(' '); + } + first = false; + serialized.append(filter); + } + + return serialized; } std::ostream& operator<<( std::ostream& out, lineOfChars value ) { diff --git a/src/catch2/reporters/catch_reporter_helpers.hpp b/src/catch2/reporters/catch_reporter_helpers.hpp index 96fd51d3..88e7636b 100644 --- a/src/catch2/reporters/catch_reporter_helpers.hpp +++ b/src/catch2/reporters/catch_reporter_helpers.hpp @@ -15,7 +15,7 @@ namespace Catch { //! Should the reporter show bool shouldShowDuration( IConfig const& config, double duration ); - std::string serializeFilters( std::vector const& container ); + std::string serializeFilters( std::vector const& filters ); struct lineOfChars { char c;