mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-16 10:05:39 +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:
@@ -11,7 +11,6 @@
|
||||
#include "catch_stream.h"
|
||||
#include "catch_compiler_capabilities.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
namespace Catch {
|
||||
@@ -73,10 +72,9 @@ namespace Catch {
|
||||
|
||||
template<typename T>
|
||||
XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {
|
||||
m_oss.clear();
|
||||
m_oss.str(std::string());
|
||||
m_oss << attribute;
|
||||
return writeAttribute( name, m_oss.str() );
|
||||
ReusableStringStream rss;
|
||||
rss << attribute;
|
||||
return writeAttribute( name, rss.str() );
|
||||
}
|
||||
|
||||
XmlWriter& writeText( std::string const& text, bool indent = true );
|
||||
@@ -100,7 +98,6 @@ namespace Catch {
|
||||
std::vector<std::string> m_tags;
|
||||
std::string m_indent;
|
||||
std::ostream& m_os;
|
||||
std::ostringstream m_oss;
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user