mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-17 10:25: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:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@@ -13,7 +14,7 @@ namespace Catch {
|
||||
: m_stream(stream),
|
||||
m_prevBuf(stream.rdbuf()),
|
||||
m_targetString(targetString) {
|
||||
stream.rdbuf(m_oss.rdbuf());
|
||||
stream.rdbuf(m_oss.get().rdbuf());
|
||||
}
|
||||
|
||||
StreamRedirect::~StreamRedirect() {
|
||||
@@ -24,8 +25,8 @@ namespace Catch {
|
||||
StdErrRedirect::StdErrRedirect(std::string & targetString)
|
||||
:m_cerrBuf(cerr().rdbuf()), m_clogBuf(clog().rdbuf()),
|
||||
m_targetString(targetString) {
|
||||
cerr().rdbuf(m_oss.rdbuf());
|
||||
clog().rdbuf(m_oss.rdbuf());
|
||||
cerr().rdbuf(m_oss.get().rdbuf());
|
||||
clog().rdbuf(m_oss.get().rdbuf());
|
||||
}
|
||||
|
||||
StdErrRedirect::~StdErrRedirect() {
|
||||
|
Reference in New Issue
Block a user