QWindowsPipeReader: remove code duplication in read()

QRingBuffer::read() implements the same loop.

Change-Id: I480fe07e2400dfaee560f22bdbf07d6cdd013eb2
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
Alex Trotsenko 2017-05-05 10:12:46 +03:00
parent ae292be869
commit 9e1f60053a
1 changed files with 2 additions and 11 deletions

View File

@ -129,17 +129,8 @@ qint64 QWindowsPipeReader::read(char *data, qint64 maxlen)
actualReadBufferSize--;
readSoFar = 1;
} else {
qint64 bytesToRead = qMin(actualReadBufferSize, maxlen);
readSoFar = 0;
while (readSoFar < bytesToRead) {
const char *ptr = readBuffer.readPointer();
qint64 bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar,
readBuffer.nextDataBlockSize());
memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock);
readSoFar += bytesToReadFromThisBlock;
readBuffer.free(bytesToReadFromThisBlock);
actualReadBufferSize -= bytesToReadFromThisBlock;
}
readSoFar = readBuffer.read(data, qMin(actualReadBufferSize, maxlen));
actualReadBufferSize -= readSoFar;
}
if (!pipeBroken) {