avoid copy in BinaryReader::readString(size_t length)
This commit is contained in:
parent
7e780d647a
commit
3d510a0682
|
@ -125,15 +125,10 @@ string BinaryReader::readLengthPrefixedString()
|
||||||
*/
|
*/
|
||||||
string BinaryReader::readString(size_t length)
|
string BinaryReader::readString(size_t length)
|
||||||
{
|
{
|
||||||
//string res;
|
string res;
|
||||||
//res.reserve(length);
|
res.resize(length);
|
||||||
//for(; length; --length) {
|
m_stream->read(&res[0], length);
|
||||||
// res.push_back(static_cast<string::value_type>(m_stream->get()));
|
return res;
|
||||||
//}
|
|
||||||
//return res;
|
|
||||||
unique_ptr<char []> buff = make_unique<char []>(length);
|
|
||||||
m_stream->read(buff.get(), length);
|
|
||||||
return string(buff.get(), length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
Loading…
Reference in New Issue