From 71de0671ba5e57c7eb34a09d24e08c8926630e0f Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Date: Tue, 18 Aug 2009 11:29:01 +0200
Subject: improve condition nesting

compilers might or might not have been clever enough to optimize it.
better safe than sorry.

Reviewed-By: mariusSO
---
 src/corelib/io/qtextstream.cpp | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 5931267..eafc561 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -736,16 +736,28 @@ bool QTextStreamPrivate::scan(const QChar **ptr, int *length, int maxlen, TokenD
             const QChar ch = *chPtr++;
             ++totalSize;
 
-            if (delimiter == Space && ch.isSpace()) {
-                foundToken = true;
-                delimSize = 1;
-            } else if (delimiter == NotSpace && !ch.isSpace()) {
-                foundToken = true;
-                delimSize = 1;
-            } else if (delimiter == EndOfLine && ch == QLatin1Char('\n')) {
-                foundToken = true;
-                delimSize = (lastChar == QLatin1Char('\r')) ? 2 : 1;
-                consumeDelimiter = true;
+            switch (delimiter) {
+            case Space:
+                if (ch.isSpace()) {
+                    foundToken = true;
+                    delimSize = 1;
+                }
+                break;
+            case NotSpace:
+                if (!ch.isSpace()) {
+                    foundToken = true;
+                    delimSize = 1;
+                }
+                break;
+            case EndOfLine:
+                if (ch == QLatin1Char('\n')) {
+                    foundToken = true;
+                    delimSize = (lastChar == QLatin1Char('\r')) ? 2 : 1;
+                    consumeDelimiter = true;
+                }
+                break;
+            default:
+                break;
             }
 
             lastChar = ch;
@@ -769,7 +781,7 @@ bool QTextStreamPrivate::scan(const QChar **ptr, int *length, int maxlen, TokenD
 
     // if we find a '\r' at the end of the data when reading lines,
     // don't make it part of the line.
-    if (totalSize > 0 && !foundToken && delimiter == EndOfLine) {
+    if (delimiter == EndOfLine && totalSize > 0 && !foundToken) {
         if (((string && stringOffset + totalSize == string->size()) || (device && device->atEnd()))
             && lastChar == QLatin1Char('\r')) {
             consumeDelimiter = true;
-- 
cgit v0.12