Use boost array sink to avoid copying buffer for BufferReader
This commit is contained in:
parent
5395290fd5
commit
81929c984b
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <boost/iostreams/seek.hpp>
|
#include <boost/iostreams/seek.hpp>
|
||||||
|
#include <boost/iostreams/stream.hpp>
|
||||||
|
#include <boost/iostreams/device/array.hpp>
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -294,7 +296,11 @@ class FileWriter
|
|||||||
class BufferReader
|
class BufferReader
|
||||||
{
|
{
|
||||||
public:
|
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)
|
if (!input_stream)
|
||||||
{
|
{
|
||||||
@ -342,7 +348,7 @@ class BufferReader
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::istringstream input_stream;
|
boost::iostreams::stream<boost::iostreams::array_source> input_stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BufferWriter
|
class BufferWriter
|
||||||
|
Loading…
Reference in New Issue
Block a user