From b36a803469795ce121ed0564f67932a5efb0ed97 Mon Sep 17 00:00:00 2001 From: gabi Date: Sat, 18 Oct 2014 19:03:41 +0300 Subject: [PATCH] pass by ref bugfix --- include/c11log/details/fast_oss.h | 8 +++----- include/c11log/details/flush_helper.h | 2 +- include/c11log/sinks/ostream_sink.h | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/c11log/details/fast_oss.h b/include/c11log/details/fast_oss.h index cb4c8f99..e6b4a8d0 100644 --- a/include/c11log/details/fast_oss.h +++ b/include/c11log/details/fast_oss.h @@ -7,7 +7,7 @@ #include #include "fast_istostr.h" #include "stack_buf.h" - +#include namespace c11log { @@ -81,8 +81,6 @@ public: fast_oss() :std::ostream(&_dev) {} ~fast_oss() = default; - - fast_oss(const fast_oss& other) :std::basic_ios(), std::ostream(&_dev), _dev(other._dev) {} @@ -108,7 +106,7 @@ public: std::string str() { - auto buffer = _dev.buf(); + auto& buffer = _dev.buf(); const char*data = buffer.data(); return std::string(data, data+buffer.size()); } @@ -152,7 +150,7 @@ public: void write_fast_oss(const fast_oss& oss) { - auto buffer = oss.buf(); + auto& buffer = oss.buf(); _dev.sputn(buffer.data(), buffer.size()); } diff --git a/include/c11log/details/flush_helper.h b/include/c11log/details/flush_helper.h index 153683ed..5285ec6c 100644 --- a/include/c11log/details/flush_helper.h +++ b/include/c11log/details/flush_helper.h @@ -18,7 +18,7 @@ public: void write(const log_msg& msg, std::ofstream& ofs) { - auto buf = msg.formatted.buf(); + auto& buf = msg.formatted.buf(); ofs.write(buf.data(), buf.size()); if(--_flush_countdown == 0) { diff --git a/include/c11log/sinks/ostream_sink.h b/include/c11log/sinks/ostream_sink.h index 0531a935..a11fc988 100644 --- a/include/c11log/sinks/ostream_sink.h +++ b/include/c11log/sinks/ostream_sink.h @@ -24,7 +24,7 @@ public: protected: virtual void _sink_it(const details::log_msg& msg) override { - auto buf = msg.formatted.buf(); + auto& buf = msg.formatted.buf(); _ostream.write(buf.data(), buf.size()); } std::ostream& _ostream;