diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-04-27 13:35:23 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-06-27 10:02:59 +0000 |
commit | 1b35f7b706b97adbc1d8935b14144b51389c0484 (patch) | |
tree | 8747133f3b09a39e52b5c82b103f901df81da804 | |
parent | 1cadc5071ced2ef3f60635d26f0b3c53cc37fc3f (diff) |
Add inlinable fastpath for namedObjectsPerComponent
Change-Id: I547142fcf3533c52f4baea12d2c58e0a64e8283a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 22 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 15 |
2 files changed, 21 insertions, 16 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index c809d497fd..773659b431 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -264,20 +264,16 @@ void CompilationUnit::markObjects(QV4::MarkStack *markStack) } } -IdentifierHash CompilationUnit::namedObjectsPerComponent(int componentObjectIndex) +IdentifierHash CompilationUnit::createNamedObjectsPerComponent(int componentObjectIndex) { - auto it = namedObjectsPerComponentCache.find(componentObjectIndex); - if (it == namedObjectsPerComponentCache.end()) { - IdentifierHash namedObjectCache(engine); - const CompiledData::Object *component = data->objectAt(componentObjectIndex); - const quint32_le *namedObjectIndexPtr = component->namedObjectsInComponentTable(); - for (quint32 i = 0; i < component->nNamedObjectsInComponent; ++i, ++namedObjectIndexPtr) { - const CompiledData::Object *namedObject = data->objectAt(*namedObjectIndexPtr); - namedObjectCache.add(runtimeStrings[namedObject->idNameIndex], namedObject->id); - } - it = namedObjectsPerComponentCache.insert(componentObjectIndex, namedObjectCache); - } - return *it; + IdentifierHash namedObjectCache(engine); + const CompiledData::Object *component = data->objectAt(componentObjectIndex); + const quint32_le *namedObjectIndexPtr = component->namedObjectsInComponentTable(); + for (quint32 i = 0; i < component->nNamedObjectsInComponent; ++i, ++namedObjectIndexPtr) { + const CompiledData::Object *namedObject = data->objectAt(*namedObjectIndexPtr); + namedObjectCache.add(runtimeStrings[namedObject->idNameIndex], namedObject->id); + } + return *namedObjectsPerComponentCache.insert(componentObjectIndex, namedObjectCache); } void CompilationUnit::finalizeCompositeType(QQmlEnginePrivate *qmlEngine) diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 46efe09924..d81ded5044 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -1053,7 +1053,7 @@ public: // mapping from component object index (CompiledData::Unit object index that points to component) to identifier hash of named objects // this is initialized on-demand by QQmlContextData QHash<int, IdentifierHash> namedObjectsPerComponentCache; - IdentifierHash namedObjectsPerComponent(int componentObjectIndex); + inline IdentifierHash namedObjectsPerComponent(int componentObjectIndex); void finalizeCompositeType(QQmlEnginePrivate *qmlEngine); @@ -1112,6 +1112,8 @@ private: QAtomicInt refCount = 1; + Q_NEVER_INLINE IdentifierHash createNamedObjectsPerComponent(int componentObjectIndex); + public: #if defined(V4_BOOTSTRAP) bool saveToDisk(const QString &outputFileName, QString *errorString); @@ -1145,11 +1147,18 @@ struct ResolvedTypeReference void doDynamicTypeCheck(); }; -#endif +IdentifierHash CompilationUnit::namedObjectsPerComponent(int componentObjectIndex) +{ + auto it = namedObjectsPerComponentCache.find(componentObjectIndex); + if (Q_UNLIKELY(it == namedObjectsPerComponentCache.end())) + return createNamedObjectsPerComponent(componentObjectIndex); + return *it; } +#endif // V4_BOOTSTRAP -} +} // CompiledData namespace +} // QV4 namespace Q_DECLARE_TYPEINFO(QV4::CompiledData::JSClassMember, Q_PRIMITIVE_TYPE); |