summaryrefslogtreecommitdiffstats
path: root/src/serialport/qserialport_wince.cpp
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2014-11-16 22:52:12 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2014-11-17 12:04:05 +0100
commit0585be1fe38474e07d72f920e63c23d0252b00fe (patch)
treeadfecc0708735fba217763d7e90b147df6ae695a /src/serialport/qserialport_wince.cpp
parent2c171c043ce3c4ca40c8dd91971192efe3c0465e (diff)
Use internal read buffer of QIODevice
It is reasonable to use the internal read buffer of QIODevice instead of additional QRingBuffer which currently are used. It will allow to reduce an overhead when copying data as now there is not an excess chain with QRingBuffer. Besides, the majority of I/O classes from QtCore (except QProcess) also use the internal QIODevice buffer which are optimized for this purpoze. Tested on Windows 8 and Linux with the virtual com0com and on-board serial ports. Change-Id: I6c3d4b84593940ccfef8c15c9fbef16bddcd002f Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Diffstat (limited to 'src/serialport/qserialport_wince.cpp')
-rw-r--r--src/serialport/qserialport_wince.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/serialport/qserialport_wince.cpp b/src/serialport/qserialport_wince.cpp
index 47c11ee6..a53aff7a 100644
--- a/src/serialport/qserialport_wince.cpp
+++ b/src/serialport/qserialport_wince.cpp
@@ -331,12 +331,12 @@ bool QSerialPortPrivate::setBreakEnabled(bool set)
qint64 QSerialPortPrivate::readData(char *data, qint64 maxSize)
{
- return readBuffer.read(data, maxSize);
+ return buffer.read(data, maxSize);
}
bool QSerialPortPrivate::waitForReadyRead(int msec)
{
- if (!readBuffer.isEmpty())
+ if (!buffer.isEmpty())
return true;
QElapsedTimer stopWatch;
@@ -499,8 +499,8 @@ bool QSerialPortPrivate::notifyRead()
DWORD bytesToRead = (policy == QSerialPort::IgnorePolicy) ? ReadChunkSize : 1;
- if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - readBuffer.size())) {
- bytesToRead = readBufferMaxSize - readBuffer.size();
+ if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - buffer.size())) {
+ bytesToRead = readBufferMaxSize - buffer.size();
if (bytesToRead == 0) {
// Buffer is full. User must read data from the buffer
// before we can read more from the port.
@@ -508,18 +508,18 @@ bool QSerialPortPrivate::notifyRead()
}
}
- char *ptr = readBuffer.reserve(bytesToRead);
+ char *ptr = buffer.reserve(bytesToRead);
DWORD readBytes = 0;
BOOL sucessResult = ::ReadFile(handle, ptr, bytesToRead, &readBytes, NULL);
if (!sucessResult) {
- readBuffer.truncate(bytesToRead);
+ buffer.chop(bytesToRead);
q->setError(QSerialPort::ReadError);
return false;
}
- readBuffer.truncate(readBytes);
+ buffer.chop(readBytes);
// Process emulate policy.
if ((policy != QSerialPort::IgnorePolicy) && parityErrorOccurred) {
@@ -528,11 +528,11 @@ bool QSerialPortPrivate::notifyRead()
switch (policy) {
case QSerialPort::SkipPolicy:
- readBuffer.getChar();
+ buffer.getChar();
return true;
case QSerialPort::PassZeroPolicy:
- readBuffer.getChar();
- readBuffer.putChar('\0');
+ buffer.getChar();
+ buffer.ungetChar('\0');
break;
case QSerialPort::StopReceivingPolicy:
// FIXME: Maybe need disable read notifier?