summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qtextstream.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-08-18 11:29:01 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-09-30 17:33:19 +0200
commit71de0671ba5e57c7eb34a09d24e08c8926630e0f (patch)
treef0cb99203966f87d5bbdbcefb881fab6e118341b /src/corelib/io/qtextstream.cpp
parentea533924ddc8a1f4d0c2d400aacee98aff952a00 (diff)
improve condition nesting
compilers might or might not have been clever enough to optimize it. better safe than sorry. Reviewed-By: mariusSO
Diffstat (limited to 'src/corelib/io/qtextstream.cpp')
-rw-r--r--src/corelib/io/qtextstream.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 593126716d..eafc5614b7 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;