diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-11-12 03:44:06 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-11-12 03:57:39 (GMT) |
commit | f809dc1b16d6a56c1a2d57997748bddb313f7f4c (patch) | |
tree | 06110acd887582bb04833b27eeca0276d314bf90 /src | |
parent | af60542fc4214cc716ffb1bdc46e2e7f6b5a6b8a (diff) | |
download | Qt-f809dc1b16d6a56c1a2d57997748bddb313f7f4c.zip Qt-f809dc1b16d6a56c1a2d57997748bddb313f7f4c.tar.gz Qt-f809dc1b16d6a56c1a2d57997748bddb313f7f4c.tar.bz2 |
Small optimization of enum detection in script.
Reviewed-by: Martin Jones
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qdeclarativetypenamescriptclass.cpp | 5 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeclass.cpp | 8 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeclass_p.h | 1 |
3 files changed, 11 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp index cba7b4a..e93aae2 100644 --- a/src/declarative/qml/qdeclarativetypenamescriptclass.cpp +++ b/src/declarative/qml/qdeclarativetypenamescriptclass.cpp @@ -109,9 +109,8 @@ QDeclarativeTypeNameScriptClass::queryProperty(Object *obj, const Identifier &na } else if (data->type) { - QString strName = toString(name); - - if (strName.at(0).isUpper()) { + if (startsWithUpper(name)) { + QString strName = toString(name); // Must be an enum if (data->mode == IncludeEnums) { // ### Optimize diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp index 8080b9f..92248a0 100644 --- a/src/script/bridge/qscriptdeclarativeclass.cpp +++ b/src/script/bridge/qscriptdeclarativeclass.cpp @@ -468,6 +468,14 @@ QString QScriptDeclarativeClass::toString(const Identifier &identifier) return QString((QChar *)r->data(), r->size()); } +bool QScriptDeclarativeClass::startsWithUpper(const Identifier &identifier) +{ + JSC::UString::Rep *r = (JSC::UString::Rep *)identifier; + if (r->size() < 1) + return false; + return QChar::category(r->data()[0]) == QChar::Letter_Uppercase; +} + quint32 QScriptDeclarativeClass::toArrayIndex(const Identifier &identifier, bool *ok) { JSC::UString::Rep *r = (JSC::UString::Rep *)identifier; diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h index 420b133..fe38eeb 100644 --- a/src/script/bridge/qscriptdeclarativeclass_p.h +++ b/src/script/bridge/qscriptdeclarativeclass_p.h @@ -126,6 +126,7 @@ public: PersistentIdentifier createPersistentIdentifier(const Identifier &); QString toString(const Identifier &); + bool startsWithUpper(const Identifier &); quint32 toArrayIndex(const Identifier &, bool *ok); virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, |