mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
A little optimization of read data from network
This commit is contained in:
parent
cbdd6bfe5a
commit
e89df78ecb
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue