From 985e7d8094437b64378370cedad76c7fb7e24c31 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 1 May 2015 07:56:18 +0400 Subject: [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) --- src/corelib/io/qtextstream.cpp | 6 +++--- 1 file 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 -- cgit v1.2.3