diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-07-08 02:47:17 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-07-08 02:48:44 (GMT) |
commit | adb496b69a49b2c20eca601fca95839199516962 (patch) | |
tree | 76ca8436177e37321d2a72bd1bdfce356667469b /src/declarative | |
parent | bd9e495a025ff8d282d54e8909771c8760ebdb3f (diff) | |
download | Qt-adb496b69a49b2c20eca601fca95839199516962.zip Qt-adb496b69a49b2c20eca601fca95839199516962.tar.gz Qt-adb496b69a49b2c20eca601fca95839199516962.tar.bz2 |
Micro optimization in QML date/time formatting functions.
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 8bf7450..c5ebe7a 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1260,11 +1260,12 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE QDate date = ctxt->argument(0).toDateTime().date(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; if (argCount == 2) { - if (ctxt->argument(1).isString()) { - QString format = ctxt->argument(1).toString(); + QScriptValue formatArg = ctxt->argument(1); + if (formatArg.isString()) { + QString format = formatArg.toString(); return engine->newVariant(qVariantFromValue(date.toString(format))); - } else if (ctxt->argument(1).isNumber()) { - enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); + } else if (formatArg.isNumber()) { + enumFormat = Qt::DateFormat(formatArg.toUInt32()); } else { return ctxt->throwError(QLatin1String("Qt.formatDate(): Invalid date format")); } @@ -1287,11 +1288,12 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE QTime date = ctxt->argument(0).toDateTime().time(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; if (argCount == 2) { - if (ctxt->argument(1).isString()) { - QString format = ctxt->argument(1).toString(); + QScriptValue formatArg = ctxt->argument(1); + if (formatArg.isString()) { + QString format = formatArg.toString(); return engine->newVariant(qVariantFromValue(date.toString(format))); - } else if (ctxt->argument(1).isNumber()) { - enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); + } else if (formatArg.isNumber()) { + enumFormat = Qt::DateFormat(formatArg.toUInt32()); } else { return ctxt->throwError(QLatin1String("Qt.formatTime(): Invalid time format")); } @@ -1377,11 +1379,12 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr QDateTime date = ctxt->argument(0).toDateTime(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; if (argCount == 2) { - if (ctxt->argument(1).isString()) { - QString format = ctxt->argument(1).toString(); + QScriptValue formatArg = ctxt->argument(1); + if (formatArg.isString()) { + QString format = formatArg.toString(); return engine->newVariant(qVariantFromValue(date.toString(format))); - } else if (ctxt->argument(1).isNumber()) { - enumFormat = Qt::DateFormat(ctxt->argument(1).toUInt32()); + } else if (formatArg.isNumber()) { + enumFormat = Qt::DateFormat(formatArg.toUInt32()); } else { return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid datetime format")); } |