From 9e1f60053a7169cc9098cc8823e1daae6d58331c Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Fri, 5 May 2017 10:12:46 +0300 Subject: QWindowsPipeReader: remove code duplication in read() QRingBuffer::read() implements the same loop. Change-Id: I480fe07e2400dfaee560f22bdbf07d6cdd013eb2 Reviewed-by: Oswald Buddenhagen Reviewed-by: Edward Welbourne --- src/corelib/io/qwindowspipereader.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/corelib/io/qwindowspipereader.cpp') diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index b8df8e8084..8bd8af3f34 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -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) { -- cgit v1.2.3