summaryrefslogtreecommitdiffstats
path: root/src/script/bridge
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-03-01 10:14:01 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2010-03-01 14:37:26 (GMT)
commitd628a467159b79c85885acb21510cb1e646a968b (patch)
treee824d1ed731a376c750cc64f1d6c84f1520c80fa /src/script/bridge
parent9d38d8005876d808f499591d1427b227f4b9764f (diff)
downloadQt-d628a467159b79c85885acb21510cb1e646a968b.zip
Qt-d628a467159b79c85885acb21510cb1e646a968b.tar.gz
Qt-d628a467159b79c85885acb21510cb1e646a968b.tar.bz2
Perform latin1 conversion directly on JSC::UString
This conversion needs to be as fast as possible since it's performed every time you access a QObject property from QtScript. Hence, we should avoid going via QString and instead do the conversion ourselves. Reviewed-by: Jedrzej Nowacki
Diffstat (limited to 'src/script/bridge')
-rw-r--r--src/script/bridge/qscriptqobject.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp
index 30e5a26..8d111f9 100644
--- a/src/script/bridge/qscriptqobject.cpp
+++ b/src/script/bridge/qscriptqobject.cpp
@@ -654,8 +654,8 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c
matchDistance += 10;
}
} else {
- QString sval = QScriptEnginePrivate::toString(exec, actual);
- int ival = m.keyToValue(sval.toLatin1());
+ JSC::UString sval = QScriptEnginePrivate::toString(exec, actual);
+ int ival = m.keyToValue(convertToLatin1(sval));
if (ival != -1) {
qVariantSetValue(v, ival);
converted = true;
@@ -1168,7 +1168,7 @@ bool QObjectDelegate::getOwnPropertySlot(QScriptObject *object, JSC::ExecState *
{
//Note: this has to be kept in sync with getOwnPropertyDescriptor
#ifndef QT_NO_PROPERTIES
- QByteArray name = QString(propertyName.ustring()).toLatin1();
+ QByteArray name = convertToLatin1(propertyName.ustring());
QObject *qobject = data->value;
if (!qobject) {
QString message = QString::fromLatin1("cannot access member `%0' of deleted QObject")
@@ -1285,7 +1285,7 @@ bool QObjectDelegate::getOwnPropertyDescriptor(QScriptObject *object, JSC::ExecS
{
//Note: this has to be kept in sync with getOwnPropertySlot abd getPropertyAttributes
#ifndef QT_NO_PROPERTIES
- QByteArray name = QString(propertyName.ustring()).toLatin1();
+ QByteArray name = convertToLatin1(propertyName.ustring());
QObject *qobject = data->value;
if (!qobject) {
QString message = QString::fromLatin1("cannot access member `%0' of deleted QObject")
@@ -1419,7 +1419,7 @@ void QObjectDelegate::put(QScriptObject *object, JSC::ExecState* exec,
JSC::JSValue value, JSC::PutPropertySlot &slot)
{
#ifndef QT_NO_PROPERTIES
- QByteArray name = ((QString)propertyName.ustring()).toLatin1();
+ QByteArray name = convertToLatin1(propertyName.ustring());
QObject *qobject = data->value;
if (!qobject) {
QString message = QString::fromLatin1("cannot access member `%0' of deleted QObject")
@@ -1517,7 +1517,7 @@ bool QObjectDelegate::deleteProperty(QScriptObject *object, JSC::ExecState *exec
bool checkDontDelete)
{
#ifndef QT_NO_PROPERTIES
- QByteArray name = ((QString)propertyName.ustring()).toLatin1();
+ QByteArray name = convertToLatin1(propertyName.ustring());
QObject *qobject = data->value;
if (!qobject) {
QString message = QString::fromLatin1("cannot access member `%0' of deleted QObject")
@@ -1567,7 +1567,7 @@ bool QObjectDelegate::getPropertyAttributes(const QScriptObject *object,
{
#ifndef QT_NO_PROPERTIES
//Note: this has to be kept in sync with getOwnPropertyDescriptor and getOwnPropertySlot
- QByteArray name = ((QString)propertyName.ustring()).toLatin1();
+ QByteArray name = convertToLatin1(propertyName.ustring());
QObject *qobject = data->value;
if (!qobject)
return false;
@@ -1853,7 +1853,7 @@ bool QMetaObjectWrapperObject::getOwnPropertySlot(
return true;
}
- QByteArray name = QString(propertyName.ustring()).toLatin1();
+ QByteArray name = convertToLatin1(propertyName.ustring());
for (int i = 0; i < meta->enumeratorCount(); ++i) {
QMetaEnum e = meta->enumerator(i);
@@ -1881,7 +1881,7 @@ void QMetaObjectWrapperObject::put(JSC::ExecState* exec, const JSC::Identifier&
}
const QMetaObject *meta = data->value;
if (meta) {
- QByteArray name = QString(propertyName.ustring()).toLatin1();
+ QByteArray name = convertToLatin1(propertyName.ustring());
for (int i = 0; i < meta->enumeratorCount(); ++i) {
QMetaEnum e = meta->enumerator(i);
for (int j = 0; j < e.keyCount(); ++j) {
@@ -1901,7 +1901,7 @@ bool QMetaObjectWrapperObject::deleteProperty(
return false;
const QMetaObject *meta = data->value;
if (meta) {
- QByteArray name = QString(propertyName.ustring()).toLatin1();
+ QByteArray name = convertToLatin1(propertyName.ustring());
for (int i = 0; i < meta->enumeratorCount(); ++i) {
QMetaEnum e = meta->enumerator(i);
for (int j = 0; j < e.keyCount(); ++j) {
@@ -1923,7 +1923,7 @@ bool QMetaObjectWrapperObject::getPropertyAttributes(JSC::ExecState *exec,
}
const QMetaObject *meta = data->value;
if (meta) {
- QByteArray name = QString(propertyName.ustring()).toLatin1();
+ QByteArray name = convertToLatin1(propertyName.ustring());
for (int i = 0; i < meta->enumeratorCount(); ++i) {
QMetaEnum e = meta->enumerator(i);
for (int j = 0; j < e.keyCount(); ++j) {