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 res;
|
||||
//res.reserve(length);
|
||||
//for(; length; --length) {
|
||||
// res.push_back(static_cast<string::value_type>(m_stream->get()));
|
||||
//}
|
||||
//return res;
|
||||
unique_ptr<char []> buff = make_unique<char []>(length);
|
||||
m_stream->read(buff.get(), length);
|
||||
return string(buff.get(), length);
|
||||
string res;
|
||||
res.resize(length);
|
||||
m_stream->read(&res[0], length);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Reference in New Issue