diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-08-18 09:29:01 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-09-30 15:33:19 (GMT) |
commit | 71de0671ba5e57c7eb34a09d24e08c8926630e0f (patch) | |
tree | f0cb99203966f87d5bbdbcefb881fab6e118341b /src/corelib/io | |
parent | ea533924ddc8a1f4d0c2d400aacee98aff952a00 (diff) | |
download | Qt-71de0671ba5e57c7eb34a09d24e08c8926630e0f.zip Qt-71de0671ba5e57c7eb34a09d24e08c8926630e0f.tar.gz Qt-71de0671ba5e57c7eb34a09d24e08c8926630e0f.tar.bz2 |
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')
-rw-r--r-- | src/corelib/io/qtextstream.cpp | 34 |
1 files 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; |