summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-02-16 18:23:18 +0100
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-02-16 19:10:38 +0100
commitd590fc729e3afaedf181da58f8b685d7597040da (patch)
tree446692610d5d85733074042115118a556f39c0e3
parente6b629f3ebc1d530218f01a735275e56bf474a18 (diff)
downloadqt4-tools-d590fc729e3afaedf181da58f8b685d7597040da.tar.gz
optimization: get rid of QString::fromUtf16() usage, part 2
QString::fromUtf16() is slow - it does a BOM check and optionally byte swapping, which is utterly irrelevant when converting internal data structures which are raw utf16 in host byte order. so replace it with QString::fromUnicode() where possible (which seems to be everywhere). the reasoning is the same as in commit e0fda52f, so not getting further reviews. Reviewed-by: denis Reviewed-by: joao
-rw-r--r--src/3rdparty/phonon/ds9/mediagraph.cpp12
-rw-r--r--src/3rdparty/phonon/waveout/mediaobject.cpp2
-rw-r--r--src/corelib/io/qprocess_symbian.cpp2
-rw-r--r--src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp8
-rw-r--r--src/multimedia/audio/qaudioinput_win32_p.cpp2
-rw-r--r--src/multimedia/audio/qaudiooutput_win32_p.cpp2
-rw-r--r--src/sql/drivers/db2/qsql_db2.cpp4
-rw-r--r--src/sql/drivers/oci/qsql_oci.cpp15
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp2
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.cpp10
10 files changed, 29 insertions, 30 deletions
diff --git a/src/3rdparty/phonon/ds9/mediagraph.cpp b/src/3rdparty/phonon/ds9/mediagraph.cpp
index a467dd75b5..3e7a68bac8 100644
--- a/src/3rdparty/phonon/ds9/mediagraph.cpp
+++ b/src/3rdparty/phonon/ds9/mediagraph.cpp
@@ -379,7 +379,7 @@ namespace Phonon
FILTER_INFO info;
filter->QueryFilterInfo(&info);
#ifdef GRAPH_DEBUG
- qDebug() << "removeFilter" << QString::fromUtf16(info.achName);
+ qDebug() << "removeFilter" << QString((const QChar *)info.achName);
#endif
if (info.pGraph) {
info.pGraph->Release();
@@ -875,7 +875,7 @@ namespace Phonon
{
FILTER_INFO info;
filter->QueryFilterInfo(&info);
- qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName);
+ qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName);
if (info.pGraph) {
info.pGraph->Release();
}
@@ -921,7 +921,7 @@ namespace Phonon
{
FILTER_INFO info;
filter->QueryFilterInfo(&info);
- qDebug() << "found a decoder filter" << QString::fromUtf16(info.achName);
+ qDebug() << "found a decoder filter" << QString((const QChar *)info.achName);
if (info.pGraph) {
info.pGraph->Release();
}
@@ -937,7 +937,7 @@ namespace Phonon
{
FILTER_INFO info;
filter->QueryFilterInfo(&info);
- qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName);
+ qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName);
if (info.pGraph) {
info.pGraph->Release();
}
@@ -956,7 +956,7 @@ namespace Phonon
{
FILTER_INFO info;
filter->QueryFilterInfo(&info);
- qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName);
+ qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName);
if (info.pGraph) {
info.pGraph->Release();
}
@@ -990,7 +990,7 @@ namespace Phonon
{
FILTER_INFO info;
filter->QueryFilterInfo(&info);
- qDebug() << "found a demuxer filter" << QString::fromUtf16(info.achName);
+ qDebug() << "found a demuxer filter" << QString((const QChar *)info.achName);
if (info.pGraph) {
info.pGraph->Release();
}
diff --git a/src/3rdparty/phonon/waveout/mediaobject.cpp b/src/3rdparty/phonon/waveout/mediaobject.cpp
index db71942afa..08af4ee2d3 100644
--- a/src/3rdparty/phonon/waveout/mediaobject.cpp
+++ b/src/3rdparty/phonon/waveout/mediaobject.cpp
@@ -50,7 +50,7 @@ namespace Phonon
{
ushort b[256];
waveOutGetErrorText(error, (LPWSTR)b, 256);
- return QString::fromUtf16(b);
+ return QString((const QChar *)b);
}
class WorkerThread : public QThread
diff --git a/src/corelib/io/qprocess_symbian.cpp b/src/corelib/io/qprocess_symbian.cpp
index 75cde51561..07d10ad616 100644
--- a/src/corelib/io/qprocess_symbian.cpp
+++ b/src/corelib/io/qprocess_symbian.cpp
@@ -1002,7 +1002,7 @@ bool QProcessPrivate::waitForDeadChild()
TExitCategoryName catName = symbianProcess->ExitCategory();
qDebug() << "QProcessPrivate::waitForDeadChild() dead with exitCode"
<< exitCode << ", crashed:" << crashed
- << ", category:" << QString::fromUtf16(catName.Ptr());
+ << ", category:" << QString((const QChar *)catName.Ptr());
#endif
} else {
QPROCESS_DEBUG_PRINT("QProcessPrivate::waitForDeadChild() not dead!");
diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
index 955a880242..67dc90ca72 100644
--- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
+++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp
@@ -218,7 +218,7 @@ void QAudioDeviceInfoInternal::updateLists()
for(i=0;i<iNumDevs;i++) {
if(waveOutGetDevCaps(i, &woc, sizeof(WAVEOUTCAPS))
== MMSYSERR_NOERROR) {
- tmp = QString::fromUtf16((const unsigned short*)woc.szPname);
+ tmp = QString((const QChar *)woc.szPname);
if(tmp.compare(device) == 0) {
match = true;
fmt = woc.dwFormats;
@@ -238,7 +238,7 @@ void QAudioDeviceInfoInternal::updateLists()
for(i=0;i<iNumDevs;i++) {
if(waveInGetDevCaps(i, &woc, sizeof(WAVEINCAPS))
== MMSYSERR_NOERROR) {
- tmp = QString::fromUtf16((const unsigned short*)woc.szPname);
+ tmp = QString((const QChar *)woc.szPname);
if(tmp.compare(device) == 0) {
match = true;
fmt = woc.dwFormats;
@@ -347,7 +347,7 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
for(i=0;i<iNumDevs;i++) {
if(waveOutGetDevCaps(i, &woc, sizeof(WAVEOUTCAPS))
== MMSYSERR_NOERROR) {
- devices.append(QString::fromUtf16((const unsigned short*)woc.szPname).toLocal8Bit().constData());
+ devices.append(QString((const QChar *)woc.szPname).toLocal8Bit().constData());
}
}
} else {
@@ -357,7 +357,7 @@ QList<QByteArray> QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode)
for(i=0;i<iNumDevs;i++) {
if(waveInGetDevCaps(i, &woc, sizeof(WAVEINCAPS))
== MMSYSERR_NOERROR) {
- devices.append(QString::fromUtf16((const unsigned short*)woc.szPname).toLocal8Bit().constData());
+ devices.append(QString((const QChar *)woc.szPname).toLocal8Bit().constData());
}
}
diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp
index 84fd2a58be..cc4fdee553 100644
--- a/src/multimedia/audio/qaudioinput_win32_p.cpp
+++ b/src/multimedia/audio/qaudioinput_win32_p.cpp
@@ -255,7 +255,7 @@ bool QAudioInputPrivate::open()
if(waveInGetDevCaps(ii, &wic, sizeof(WAVEINCAPS))
== MMSYSERR_NOERROR) {
QString tmp;
- tmp = QString::fromUtf16((const unsigned short*)wic.szPname);
+ tmp = QString((const QChar *)wic.szPname);
if(tmp.compare(QLatin1String(m_device)) == 0) {
devId = ii;
break;
diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp
index c31e04841a..bce45c1214 100644
--- a/src/multimedia/audio/qaudiooutput_win32_p.cpp
+++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp
@@ -250,7 +250,7 @@ bool QAudioOutputPrivate::open()
if(waveOutGetDevCaps(ii, &woc, sizeof(WAVEOUTCAPS))
== MMSYSERR_NOERROR) {
QString tmp;
- tmp = QString::fromUtf16((const unsigned short*)woc.szPname);
+ tmp = QString((const QChar *)woc.szPname);
if(tmp.compare(QLatin1String(m_device)) == 0) {
devId = ii;
break;
diff --git a/src/sql/drivers/db2/qsql_db2.cpp b/src/sql/drivers/db2/qsql_db2.cpp
index d5b398429d..ea0b42e0d7 100644
--- a/src/sql/drivers/db2/qsql_db2.cpp
+++ b/src/sql/drivers/db2/qsql_db2.cpp
@@ -109,7 +109,7 @@ public:
static QString qFromTChar(SQLTCHAR* str)
{
- return QString::fromUtf16(str);
+ return QString((const QChar *)str);
}
// dangerous!! (but fast). Don't use in functions that
@@ -833,7 +833,7 @@ bool QDB2Result::exec()
break;
case QVariant::String:
if (bindValueType(i) & QSql::Out)
- values[i] = QString::fromUtf16((ushort*)tmpStorage.takeFirst().constData());
+ values[i] = QString((const QChar *)tmpStorage.takeFirst().constData());
break;
default: {
values[i] = QString::fromAscii(tmpStorage.takeFirst().constData());
diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp
index 01c4124c9f..b5c85e696b 100644
--- a/src/sql/drivers/oci/qsql_oci.cpp
+++ b/src/sql/drivers/oci/qsql_oci.cpp
@@ -364,8 +364,8 @@ static void qOraOutValue(QVariant &value, QList<QByteArray> &storage)
value = qMakeDate(storage.takeFirst());
break;
case QVariant::String:
- value = QString::fromUtf16(
- reinterpret_cast<const ushort *>(storage.takeFirst().constData()));
+ value = QString(
+ reinterpret_cast<const QChar *>(storage.takeFirst().constData()));
break;
default:
break; //nothing
@@ -454,7 +454,7 @@ QString qOraWarn(OCIError *err, int *errorCode)
OCI_HTYPE_ERROR);
if (errorCode)
*errorCode = errcode;
- return QString::fromUtf16(reinterpret_cast<const ushort *>(errbuf));
+ return QString(reinterpret_cast<const QChar *>(errbuf));
}
void qOraWarning(const char* msg, OCIError *err)
@@ -989,8 +989,7 @@ int QOCICols::readPiecewise(QVector<QVariant> &values, int index)
} else {
if (isStringField) {
QString str = values.at(fieldNum + index).toString();
- str += QString::fromUtf16(reinterpret_cast<const ushort *>(col),
- chunkSize / 2);
+ str += QString(reinterpret_cast<const QChar *>(col), chunkSize / 2);
values[fieldNum + index] = str;
fieldInf[fieldNum].ind = 0;
} else {
@@ -1457,7 +1456,7 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVector<QVariant> &boundValues, b
break;
case SQLT_STR:
- (*list)[r] = QString::fromUtf16(reinterpret_cast<ushort *>(data
+ (*list)[r] = QString(reinterpret_cast<const QChar *>(data
+ r * columns[i].maxLen));
break;
@@ -1608,7 +1607,7 @@ void QOCICols::getValues(QVector<QVariant> &v, int index)
}
// else fall through
case QVariant::String:
- v[index + i] = QString::fromUtf16(reinterpret_cast<const ushort *>(fld.data));
+ v[index + i] = QString(reinterpret_cast<const QChar *>(fld.data));
break;
case QVariant::ByteArray:
if (fld.len > 0)
@@ -2102,7 +2101,7 @@ bool QOCIDriver::open(const QString & db,
qWarning("QOCIDriver::open: could not get Oracle server version.");
} else {
QString versionStr;
- versionStr = QString::fromUtf16(reinterpret_cast<ushort *>(vertxt));
+ versionStr = QString(reinterpret_cast<const QChar *>(vertxt));
QRegExp vers(QLatin1String("([0-9]+)\\.[0-9\\.]+[0-9]"));
if (vers.indexIn(versionStr) >= 0)
d->serverVersion = vers.cap(1).toInt();
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 18bc743670..fab3ab3c2b 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -1558,7 +1558,7 @@ bool QODBCResult::exec()
case QVariant::String:
if (d->unicode) {
if (bindValueType(i) & QSql::Out)
- values[i] = QString::fromUtf16((ushort*)tmpStorage.takeFirst().constData());
+ values[i] = QString((QChar *)tmpStorage.takeFirst().constData());
break;
}
// fall through
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp
index d3be304b02..24dcad9f18 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.cpp
+++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp
@@ -95,7 +95,7 @@ static QSqlError qMakeError(sqlite3 *access, const QString &descr, QSqlError::Er
int errorCode = -1)
{
return QSqlError(descr,
- QString::fromUtf16(static_cast<const ushort *>(sqlite3_errmsg16(access))),
+ QString(reinterpret_cast<const QChar *>(sqlite3_errmsg16(access))),
type, errorCode);
}
@@ -162,13 +162,13 @@ void QSQLiteResultPrivate::initColumns(bool emptyResultset)
q->init(nCols);
for (int i = 0; i < nCols; ++i) {
- QString colName = QString::fromUtf16(
- static_cast<const ushort *>(sqlite3_column_name16(stmt, i))
+ QString colName = QString(reinterpret_cast<const QChar *>(
+ sqlite3_column_name16(stmt, i))
).remove(QLatin1Char('"'));
// must use typeName for resolving the type to match QSqliteDriver::record
- QString typeName = QString::fromUtf16(
- static_cast<const ushort *>(sqlite3_column_decltype16(stmt, i)));
+ QString typeName = QString(reinterpret_cast<const QChar *>(
+ sqlite3_column_decltype16(stmt, i)));
int dotIdx = colName.lastIndexOf(QLatin1Char('.'));
QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), qGetColumnType(typeName));