QLocalSocket: always open outer QIODevice in unbuffered mode

The actual buffering is performed either in the inner socket (Unix),
or in the pipeReader (Windows). To avoid unnecessary copying of data
between buffers, enforce unbuffered mode for all implementations,
which slightly improves read performance.

Change-Id: Idb2a09f35823b9945c71231710290be12d9930f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
Alex Trotsenko 2021-07-19 19:28:14 +03:00
parent 3bc976c2bd
commit 6f682d4876
2 changed files with 3 additions and 1 deletions

View File

@ -396,6 +396,8 @@ QLocalSocket::QLocalSocket(QObject * parent)
: QIODevice(*new QLocalSocketPrivate, parent)
{
Q_D(QLocalSocket);
d->readBufferChunkSize = 0; // force QIODevice unbuffered mode
d->init();
}

View File

@ -357,7 +357,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
fullServerName = connectingPathName;
if (unixSocket.setSocketDescriptor(connectingSocket,
QAbstractSocket::ConnectedState, connectingOpenMode)) {
q->QIODevice::open(connectingOpenMode | QIODevice::Unbuffered);
q->QIODevice::open(connectingOpenMode);
q->emit connected();
} else {
QString function = QLatin1String("QLocalSocket::connectToServer");