From 5c5e4582d60ce38868e838bced73f52febec5841 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Wed, 5 Nov 2014 12:38:02 +0200 Subject: [PATCH] QTextStreamPrivate::scan(): remove unnecessary checks The delimiter search scan() loop detects a device or string reaching the end of input and size limits. After that, 'false' is returned only when no data was read at all. So, there is no a reason to test anything except 'totalSize'. Change-Id: Ib9cc21c0f4b7863c2dafb1bb074c5cda07387b8f Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/corelib/io/qtextstream.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 730329d21d..5f3177e58f 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -681,15 +681,9 @@ bool QTextStreamPrivate::scan(const QChar **ptr, int *length, int maxlen, TokenD && (!maxlen || totalSize < maxlen) && (device && (canStillReadFromDevice = fillReadBuffer()))); - // if the token was not found, but we reached the end of input, - // then we accept what we got. if we are not at the end of input, - // we return false. - if (!foundToken && (!maxlen || totalSize < maxlen) - && (totalSize == 0 - || (string && stringOffset + totalSize < string->size()) - || (device && !device->atEnd() && canStillReadFromDevice))) { + if (totalSize == 0) { #if defined (QTEXTSTREAM_DEBUG) - qDebug("QTextStreamPrivate::scan() did not find the token."); + qDebug("QTextStreamPrivate::scan() reached the end of input."); #endif return false; }