summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-29 15:44:12 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-02-01 13:13:43 (GMT)
commite0fda52fde32458c4a42f04bd62b5e37f14c4bfd (patch)
treedf8154a8878f767c87a5cae8ad9d1dc4e17ebffd /src/sql
parent45591e13862963fb29c13e0c5bfe39330883c579 (diff)
downloadQt-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/sql')
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.cpp4
-rw-r--r--src/sql/kernel/qsqlresult.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp
index 9dbefaf..9fff552 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.cpp
+++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp
@@ -245,9 +245,9 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i
values[i + idx] = QVariant(QVariant::String);
break;
default:
- values[i + idx] = QString::fromUtf16(static_cast<const ushort *>(
+ values[i + idx] = QString(reinterpret_cast<const QChar *>(
sqlite3_column_text16(stmt, i)),
- sqlite3_column_bytes16(stmt, i) / sizeof(ushort));
+ sqlite3_column_bytes16(stmt, i) / sizeof(QChar));
break;
}
}
diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp
index 5f12b55..3d63f88 100644
--- a/src/sql/kernel/qsqlresult.cpp
+++ b/src/sql/kernel/qsqlresult.cpp
@@ -136,7 +136,7 @@ static QString qFieldSerial(int i)
i >>= 4;
}
- return QString::fromUtf16(arr, int(ptr - arr) + 1);
+ return QString(reinterpret_cast<const QChar *>(arr), int(ptr - arr) + 1);
}
static bool qIsAlnum(QChar ch)