summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qtextstream.cpp
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-05-01 07:56:18 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-05-01 08:49:11 +0000
commit985e7d8094437b64378370cedad76c7fb7e24c31 (patch)
tree33272863db4a2750d0456ecd655ecfd650de0346 /src/corelib/io/qtextstream.cpp
parent315b359bc199fcc9492fa33f573d6c43d22b3b6a (diff)
[QTextStream::read.*] Return earlier when nothing has been read
There is no any sense in detecting the encoding of an empty string ;) Change-Id: I1c7af07bd7c3e7e7cf67421a2cb3a1123ca57650 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/io/qtextstream.cpp')
-rw-r--r--src/corelib/io/qtextstream.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 6149a04a74..5fe4cfef9d 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -447,6 +447,9 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
bytesRead = device->read(buf, sizeof(buf));
}
+ if (bytesRead <= 0)
+ return false;
+
#ifndef QT_NO_TEXTCODEC
// codec auto detection, explicitly defaults to locale encoding if the
// codec has been set to 0.
@@ -470,9 +473,6 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
qt_prettyDebug(buf, qMin(32,int(bytesRead)) , int(bytesRead)).constData(), int(sizeof(buf)), int(bytesRead));
#endif
- if (bytesRead <= 0)
- return false;
-
int oldReadBufferSize = readBuffer.size();
#ifndef QT_NO_TEXTCODEC
// convert to unicode