diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-06-23 18:26:10 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2021-07-06 17:52:58 +0300 |
commit | b3fbfcd3738a0ff864439499390513b95ca671aa (patch) | |
tree | ac274d4652ea3415e9b0ef302c3c6bd146e15e4d /src/network/socket/qlocalsocket_unix.cpp | |
parent | 46d2ba1ea4d0e5f1a2ae1d1801e416e487ea45b4 (diff) |
QLocalSocket: reimplement readLineData() function
The base implementation reads data using repeated calls to getChar(),
which is quite slow.
Change-Id: Ie46624df63791b2cdd3c8a28fe3327427d942505
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/network/socket/qlocalsocket_unix.cpp')
-rw-r--r-- | src/network/socket/qlocalsocket_unix.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 5e050ad323..4dc542f2e3 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -483,6 +483,16 @@ qint64 QLocalSocket::readData(char *data, qint64 c) return d->unixSocket.read(data, c); } +qint64 QLocalSocket::readLineData(char *data, qint64 maxSize) +{ + if (!maxSize) + return 0; + + // QIODevice::readLine() reserves space for the trailing '\0' byte, + // so we must read 'maxSize + 1' bytes. + return d_func()->unixSocket.readLine(data, maxSize + 1); +} + qint64 QLocalSocket::skipData(qint64 maxSize) { return d_func()->unixSocket.skip(maxSize); |