aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/v8/qv8engine_p.h
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-06-14 16:17:39 +1000
committerAaron Kennedy <aaron.kennedy@nokia.com>2011-06-14 16:17:39 +1000
commit3ad5beee4c3fbbc855b84c8982c5458d634f1dee (patch)
tree7ddf1bcf379a16185c1c52f53bb689767122c1e9 /src/declarative/qml/v8/qv8engine_p.h
parent7456055c2df733dbbe2ca5967f512c2555ca31d4 (diff)
Performance improvements
There are two main changes here. First, where possible, we mark properties as "IsDirect" which means that they exist in a C++ QMetaObject (as opposed to a dynamic meta object), which allows us to call QObject::qt_metacall() directly, bypassing any dynamic meta object stuff. The second change is to use an ascii string comparator in V8 where possible. V8 stores ASCII string internally as ASCII strings, and asking it to compare them to a UTF16 string requires a conversion.
Diffstat (limited to 'src/declarative/qml/v8/qv8engine_p.h')
-rw-r--r--src/declarative/qml/v8/qv8engine_p.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/declarative/qml/v8/qv8engine_p.h b/src/declarative/qml/v8/qv8engine_p.h
index b29f465e95..46ba0a4431 100644
--- a/src/declarative/qml/v8/qv8engine_p.h
+++ b/src/declarative/qml/v8/qv8engine_p.h
@@ -128,11 +128,18 @@ public:
};
template<class T>
-T *v8_resource_cast(v8::Handle<v8::Object> object) {
+inline T *v8_resource_cast(v8::Handle<v8::Object> object) {
QV8ObjectResource *resource = static_cast<QV8ObjectResource *>(object->GetExternalResource());
return (resource && (quint32)resource->resourceType() == (quint32)T::V8ResourceType)?static_cast<T *>(resource):0;
}
+template<class T>
+inline T *v8_resource_check(v8::Handle<v8::Object> object) {
+ T *resource = static_cast<T *>(object->GetExternalResource());
+ Q_ASSERT(resource && resource->resourceType() == (quint32)T::V8ResourceType);
+ return resource;
+}
+
// Used to allow a QObject method take and return raw V8 handles without having to expose
// v8 in the public API.
// Use like this: