From 81929c984b5a8441fe3676cf5dee7b557123718f Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Mon, 26 Mar 2018 14:23:52 +0000 Subject: [PATCH] Use boost array sink to avoid copying buffer for BufferReader --- include/storage/io.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/storage/io.hpp b/include/storage/io.hpp index 159c149b7..fe2351ca3 100644 --- a/include/storage/io.hpp +++ b/include/storage/io.hpp @@ -12,6 +12,8 @@ #include #include +#include +#include #include #include @@ -294,7 +296,11 @@ class FileWriter class BufferReader { public: - BufferReader(const std::string &buffer) : input_stream(buffer, std::ios::binary) + BufferReader(const std::string &buffer) : BufferReader(buffer.data(), buffer.size()) + { + } + + BufferReader(const char* buffer, const std::size_t size) : input_stream(boost::iostreams::array_source(buffer, size)) { if (!input_stream) { @@ -342,7 +348,7 @@ class BufferReader } private: - std::istringstream input_stream; + boost::iostreams::stream input_stream; }; class BufferWriter