mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-14 01:15: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:
@@ -32,13 +32,12 @@ namespace Catch {
|
||||
|
||||
public:
|
||||
StreamRedirect(std::ostream& stream, std::string& targetString);
|
||||
|
||||
~StreamRedirect();
|
||||
|
||||
private:
|
||||
std::ostream& m_stream;
|
||||
std::streambuf* m_prevBuf;
|
||||
std::ostringstream m_oss;
|
||||
ReusableStringStream m_oss;
|
||||
std::string& m_targetString;
|
||||
};
|
||||
|
||||
@@ -52,7 +51,7 @@ namespace Catch {
|
||||
private:
|
||||
std::streambuf* m_cerrBuf;
|
||||
std::streambuf* m_clogBuf;
|
||||
std::ostringstream m_oss;
|
||||
ReusableStringStream m_oss;
|
||||
std::string& m_targetString;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user