diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-10-22 16:27:50 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-10-23 10:18:24 (GMT) |
commit | d610da0f40819213fd45bf77f6c2131769df693d (patch) | |
tree | 42c45c142cf57554a5600b1fdc87be5cb765a04b /src/script/api/qscriptengine_p.h | |
parent | 7bfa219ebd050523ecd0d72ad7154e1ce3b83ae9 (diff) | |
download | Qt-d610da0f40819213fd45bf77f6c2131769df693d.zip Qt-d610da0f40819213fd45bf77f6c2131769df693d.tar.gz Qt-d610da0f40819213fd45bf77f6c2131769df693d.tar.bz2 |
Inline internal property lookup function
Also avoid looking up the object's own properties twice
(before we called getOwnPropertySlot() and then getPropertySlot()
on the same object).
Makes QScriptValue::property() ~20% faster when calling it on an "empty" object.
Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/script/api/qscriptengine_p.h')
-rw-r--r-- | src/script/api/qscriptengine_p.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index c9faa46..a16785c 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -489,6 +489,28 @@ inline QScriptValue QScriptValuePrivate::property(const QString &name, int resol return property(JSC::Identifier(exec, name), resolveMode); } +inline QScriptValue QScriptValuePrivate::property(const JSC::Identifier &id, int resolveMode) const +{ + Q_ASSERT(isObject()); + JSC::ExecState *exec = engine->currentFrame; + JSC::JSObject *object = JSC::asObject(jscValue); + JSC::PropertySlot slot(object); + if ((resolveMode & QScriptValue::ResolvePrototype) && object->getPropertySlot(exec, id, slot)) + return engine->scriptValueFromJSCValue(slot.getValue(exec, id)); + return propertyHelper(id, resolveMode); +} + +inline QScriptValue QScriptValuePrivate::property(quint32 index, int resolveMode) const +{ + Q_ASSERT(isObject()); + JSC::ExecState *exec = engine->currentFrame; + JSC::JSObject *object = JSC::asObject(jscValue); + JSC::PropertySlot slot(object); + if ((resolveMode & QScriptValue::ResolvePrototype) && object->getPropertySlot(exec, index, slot)) + return engine->scriptValueFromJSCValue(slot.getValue(exec, index)); + return propertyHelper(index, resolveMode); +} + inline void* QScriptValuePrivate::operator new(size_t size, QScriptEnginePrivate *engine) { if (engine) |