mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-17 02:25:38 +02:00
Introduced ReusableStringStream and removed all uses of std::ostringstream from the main path
ReusableStringStream holds a std::ostringstream internally, but only exposes the ostream interface. It caches a pool of ostringstreams in a vector which is currently global, but will be made thread-local. Altogether this should enable both runtime and compile-time benefits. although more work is needed to realise the compile time opportunities.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#include "../internal/catch_timer.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -230,15 +230,15 @@ namespace Catch {
|
||||
xml.writeAttribute( "message", result.getExpandedExpression() );
|
||||
xml.writeAttribute( "type", result.getTestMacroName() );
|
||||
|
||||
std::ostringstream oss;
|
||||
ReusableStringStream rss;
|
||||
if( !result.getMessage().empty() )
|
||||
oss << result.getMessage() << '\n';
|
||||
rss << result.getMessage() << '\n';
|
||||
for( auto const& msg : stats.infoMessages )
|
||||
if( msg.type == ResultWas::Info )
|
||||
oss << msg.message << '\n';
|
||||
rss << msg.message << '\n';
|
||||
|
||||
oss << "at " << result.getSourceInfo();
|
||||
xml.writeText( oss.str(), false );
|
||||
rss << "at " << result.getSourceInfo();
|
||||
xml.writeText( rss.str(), false );
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user