A little optimization of read data from network

This commit is contained in:
Abs62 2018-03-12 20:22:38 +03:00
parent cbdd6bfe5a
commit e89df78ecb
2 changed files with 5 additions and 5 deletions

View file

@ -185,7 +185,9 @@ using std::string;
void AllowFrameReply::readDataFromBase()
{
QByteArray data = baseReply->readAll();
QByteArray data;
data.resize( baseReply->bytesAvailable() );
baseReply->read( data.data(), data.size() );
buffer += data;
emit readyRead();
}

View file

@ -61,13 +61,11 @@ void WebMultimediaDownload::replyFinished( QNetworkReply * r )
// Handle reply data
QByteArray all = r->readAll();
Mutex::Lock _( dataMutex );
data.resize( all.size() );
data.resize( r->bytesAvailable() );
memcpy( data.data(), all.data(), all.size() );
r->read( data.data(), data.size() );
hasAnyData = true;
}