diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2014-11-12 20:07:27 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-11-21 16:36:10 +0100 |
commit | f62bf4e76d9ae9bf685e37ace3dc6d2365e2f82f (patch) | |
tree | e3fe77546b69c0a1b82dec7306896a4b31876954 /src/qml/jsruntime/qv4internalclass.cpp | |
parent | f58b5229a31e9fec49b4eb055c56f9a78e423866 (diff) |
Changed InternalClass to store Identifier* instead of String*
All members are identifiers anyway, so this gets rid of a ### and
also simplifies some of the call sites by removing the need for a
scoped string.
Change-Id: Ic6b550cdb97afa5a4b0fa7e9b13e7768ed3f6bd8
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4internalclass.cpp | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp index 7247228091..bd76fa6ec7 100644 --- a/src/qml/jsruntime/qv4internalclass.cpp +++ b/src/qml/jsruntime/qv4internalclass.cpp @@ -147,7 +147,7 @@ InternalClass::InternalClass(const QV4::InternalClass &other) void InternalClass::changeMember(Object *object, String *string, PropertyAttributes data, uint *index) { uint idx; - InternalClass *newClass = object->internalClass()->changeMember(string, data, &idx); + InternalClass *newClass = object->internalClass()->changeMember(string->identifier(), data, &idx); if (index) *index = idx; @@ -161,10 +161,10 @@ void InternalClass::changeMember(Object *object, String *string, PropertyAttribu object->setInternalClass(newClass); } -InternalClass *InternalClass::changeMember(String *string, PropertyAttributes data, uint *index) +InternalClass *InternalClass::changeMember(Identifier *identifier, PropertyAttributes data, uint *index) { data.resolve(); - uint idx = find(string); + uint idx = find(identifier); Q_ASSERT(idx != UINT_MAX); if (index) @@ -173,7 +173,7 @@ InternalClass *InternalClass::changeMember(String *string, PropertyAttributes da if (data == propertyData.at(idx)) return this; - Transition t = { { string->d()->identifier }, (int)data.flags() }; + Transition t = { { identifier }, (int)data.flags() }; QHash<Transition, InternalClass *>::const_iterator tit = transitions.constFind(t); if (tit != transitions.constEnd()) return tit.value(); @@ -273,28 +273,32 @@ void InternalClass::addMember(Object *object, String *string, PropertyAttributes } uint idx; - InternalClass *newClass = object->internalClass()->addMemberImpl(string, data, &idx); + InternalClass *newClass = object->internalClass()->addMemberImpl(string->identifier(), data, &idx); if (index) *index = idx; object->setInternalClass(newClass); } - InternalClass *InternalClass::addMember(String *string, PropertyAttributes data, uint *index) { - data.resolve(); engine->identifierTable->identifier(string); + return addMember(string->identifier(), data, index); +} - if (propertyTable.lookup(string->d()->identifier) < size) - return changeMember(string, data, index); +InternalClass *InternalClass::addMember(Identifier *identifier, PropertyAttributes data, uint *index) +{ + data.resolve(); + + if (propertyTable.lookup(identifier) < size) + return changeMember(identifier, data, index); - return addMemberImpl(string, data, index); + return addMemberImpl(identifier, data, index); } -InternalClass *InternalClass::addMemberImpl(String *string, PropertyAttributes data, uint *index) +InternalClass *InternalClass::addMemberImpl(Identifier *identifier, PropertyAttributes data, uint *index) { - Transition t = { { string->d()->identifier }, (int)data.flags() }; + Transition t = { { identifier }, (int)data.flags() }; QHash<Transition, InternalClass *>::const_iterator tit = transitions.constFind(t); if (index) @@ -304,15 +308,10 @@ InternalClass *InternalClass::addMemberImpl(String *string, PropertyAttributes d // create a new class and add it to the tree InternalClass *newClass = engine->newClass(*this); - PropertyHash::Entry e = { string->d()->identifier, newClass->size }; + PropertyHash::Entry e = { identifier, newClass->size }; newClass->propertyTable.addEntry(e, newClass->size); - // The incoming string can come from anywhere, so make sure to - // store a string in the nameMap that's guaranteed to get - // marked properly during GC. - // #### GC - String *name = reinterpret_cast<String*>(engine->newIdentifier(string->toQString())); - newClass->nameMap.add(newClass->size, name); + newClass->nameMap.add(newClass->size, identifier); newClass->propertyData.add(newClass->size, data); ++newClass->size; if (data.isAccessor()) { @@ -369,6 +368,15 @@ uint InternalClass::find(const String *string) return UINT_MAX; } +uint InternalClass::find(const Identifier *id) +{ + uint index = propertyTable.lookup(id); + if (index < size) + return index; + + return UINT_MAX; +} + InternalClass *InternalClass::sealed() { if (m_sealed) @@ -418,7 +426,7 @@ void InternalClass::destroy() engine = 0; propertyTable.~PropertyHash(); - nameMap.~SharedInternalClassData<String *>(); + nameMap.~SharedInternalClassData<Identifier *>(); propertyData.~SharedInternalClassData<PropertyAttributes>(); if (m_sealed) |