diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2010-01-29 15:44:12 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2010-02-01 13:13:43 (GMT) |
commit | e0fda52fde32458c4a42f04bd62b5e37f14c4bfd (patch) | |
tree | df8154a8878f767c87a5cae8ad9d1dc4e17ebffd /src/corelib/kernel | |
parent | 45591e13862963fb29c13e0c5bfe39330883c579 (diff) | |
download | Qt-e0fda52fde32458c4a42f04bd62b5e37f14c4bfd.zip Qt-e0fda52fde32458c4a42f04bd62b5e37f14c4bfd.tar.gz Qt-e0fda52fde32458c4a42f04bd62b5e37f14c4bfd.tar.bz2 |
optimization: get rid of QString::fromUtf16() usage
QString::fromUtf16() is slow - it does a BOM check and optionally byte
swapping, which is utterly pointless when converting internal data
structures which are raw utf16 in host byte order anyway. so replace
it with QString::fromRawData() (for short-lived strings) or
QString(const QChar *, int) (otherwise) if possible.
Reviewed-by: axis
Reviewed-by: mariusSO
Reviewed-by: Bill King
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qcore_symbian_p.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qtranslator.cpp | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/kernel/qcore_symbian_p.cpp b/src/corelib/kernel/qcore_symbian_p.cpp index 5d2a6a5..0257ac4 100644 --- a/src/corelib/kernel/qcore_symbian_p.cpp +++ b/src/corelib/kernel/qcore_symbian_p.cpp @@ -71,7 +71,7 @@ Q_CORE_EXPORT QString qt_TDesC2QString(const TDesC& aDescriptor) #ifdef QT_NO_UNICODE return QString::fromLocal8Bit(aDescriptor.Ptr(), aDescriptor.Length()); #else - return QString::fromUtf16(aDescriptor.Ptr(), aDescriptor.Length()); + return QString(reinterpret_cast<const QChar *>(aDescriptor.Ptr()), aDescriptor.Length()); #endif } diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 005dedc..5c65416 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2219,7 +2219,8 @@ QStringList QCoreApplication::libraryPaths() TFindFile finder(fs); TInt err = finder.FindByDir(tempPathPtr, tempPathPtr); while (err == KErrNone) { - QString foundDir = QString::fromUtf16(finder.File().Ptr(), finder.File().Length()); + QString foundDir(reinterpret_cast<const QChar *>(finder.File().Ptr()), + finder.File().Length()); foundDir = QDir(foundDir).canonicalPath(); if (!app_libpaths->contains(foundDir)) app_libpaths->append(foundDir); diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index b7e6ea0..7d1e1d3 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -633,7 +633,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context, end: if (!tn) return QString(); - QString str = QString::fromUtf16((const ushort *)tn, tn_length/2); + QString str = QString((const QChar *)tn, tn_length/2); if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) { for (int i = 0; i < str.length(); ++i) str[i] = QChar((str.at(i).unicode() >> 8) + ((str.at(i).unicode() << 8) & 0xff00)); |