diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-12-15 16:07:13 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-12-16 14:50:05 (GMT) |
commit | 6d84ab27595ad9b570ccaf5a3230e83aa878ef06 (patch) | |
tree | 4bfd275b483068b1bbc6005081cb5a0bf5e56565 /src/corelib/io | |
parent | cc598ec6b0d396ab11de20a3f21064522578960c (diff) | |
download | Qt-6d84ab27595ad9b570ccaf5a3230e83aa878ef06.zip Qt-6d84ab27595ad9b570ccaf5a3230e83aa878ef06.tar.gz Qt-6d84ab27595ad9b570ccaf5a3230e83aa878ef06.tar.bz2 |
An optimisation to QTextStream
Using QLocale::operator== is faster than comparing languages, because when
getting a language from a default constructed QLocale object, it initializes
the system locale and quieries the system which languge it supports.
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qtextstream.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 594718e..47f340c 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -440,7 +440,7 @@ QTextStreamPrivate::QTextStreamPrivate(QTextStream *q_ptr) readConverterSavedState(0), #endif readConverterSavedStateOffset(0), - locale(QLocale::C) + locale(QLocale::c()) { this->q_ptr = q_ptr; reset(); @@ -1806,8 +1806,7 @@ QTextStreamPrivate::NumberParsingStatus QTextStreamPrivate::getNumber(qulonglong if (ch.isDigit()) { val *= 10; val += ch.digitValue(); - } else if (locale.language() != QLocale::C - && ch == locale.groupSeparator()) { + } else if (locale != QLocale::c() && ch == locale.groupSeparator()) { continue; } else { ungetChar(ch); @@ -1958,7 +1957,7 @@ bool QTextStreamPrivate::getReal(double *f) else if (lc == locale.negativeSign().toLower() || lc == locale.positiveSign().toLower()) input = InputSign; - else if (locale.language() != QLocale::C // backward-compatibility + else if (locale != QLocale::c() // backward-compatibility && lc == locale.groupSeparator().toLower()) input = InputDigit; // well, it isn't a digit, but no one cares. else @@ -2283,7 +2282,7 @@ bool QTextStreamPrivate::putNumber(qulonglong number, bool negative) // add thousands group separators. For backward compatibility we // don't add a group separator for C locale. - if (locale.language() != QLocale::C) + if (locale != QLocale::c()) flags |= QLocalePrivate::ThousandsGroup; const QLocalePrivate *dd = locale.d(); |