diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-09-23 11:35:54 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-09-27 08:34:06 +0000 |
commit | 9df44b2b502f9ab9a379c8454b000d2085aed744 (patch) | |
tree | 458f90b6c8d7bd1c45696cb4b56db30f30e504c4 /src/qml/jsruntime/qv4internalclass_p.h | |
parent | b6f2b4308b024a92d18bdb81db9fa7dc37213eb3 (diff) |
Refactor deletion of properties
In line with the previous commit, allow entries with a valid
PropertyKey, but invalid attributes in the InternalClass. Those
entries mark a deleted property.
This cleans up/unifies some of the code in the internal class
implementation and allows re-using the slot if a deleted property
gets added again.
Change-Id: I1bada697486e3cafce7689bae87b7f884200dd99
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4internalclass_p.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h index 2d60a0048f..681cbda5f9 100644 --- a/src/qml/jsruntime/qv4internalclass_p.h +++ b/src/qml/jsruntime/qv4internalclass_p.h @@ -314,8 +314,7 @@ struct InternalClassTransition PrototypeChange = 0x201, ProtoClass = 0x202, Sealed = 0x203, - Frozen = 0x204, - RemoveMember = -1 + Frozen = 0x204 }; bool operator==(const InternalClassTransition &other) const @@ -378,7 +377,8 @@ struct InternalClass : Base { PropertyHash::Entry *e = propertyTable.lookup(id); if (e && e->index < size) { PropertyAttributes a = propertyData.at(e->index); - return { e->index, e->setterIndex, a }; + if (!a.isEmpty()) + return { e->index, e->setterIndex, a }; } return { UINT_MAX, UINT_MAX, Attr_Invalid }; @@ -395,8 +395,11 @@ struct InternalClass : Base { Q_ASSERT(id.isStringOrSymbol()); PropertyHash::Entry *e = propertyTable.lookup(id); - if (e && e->index < size) - return { e->index, propertyData.at(e->index) }; + if (e && e->index < size) { + PropertyAttributes a = propertyData.at(e->index); + if (!a.isEmpty()) + return { e->index, a }; + } return { UINT_MAX, Attr_Invalid }; } @@ -408,11 +411,13 @@ struct InternalClass : Base { PropertyHash::Entry *e = propertyTable.lookup(id); if (e && e->index < size) { PropertyAttributes a = propertyData.at(e->index); - if (a.isAccessor()) { - Q_ASSERT(e->setterIndex != UINT_MAX); - return { e->setterIndex, a }; + if (!a.isEmpty()) { + if (a.isAccessor()) { + Q_ASSERT(e->setterIndex != UINT_MAX); + return { e->setterIndex, a }; + } + return { e->index, a }; } - return { e->index, a }; } return { UINT_MAX, Attr_Invalid }; @@ -423,8 +428,10 @@ struct InternalClass : Base { Q_ASSERT(id.isStringOrSymbol()); PropertyHash::Entry *e = propertyTable.lookup(id); - if (e && e->index < size) + if (e && e->index < size) { + Q_ASSERT(!propertyData.at(e->index).isEmpty()); return e->index; + } return UINT_MAX; } @@ -434,8 +441,10 @@ struct InternalClass : Base { Q_ASSERT(id.isStringOrSymbol()); PropertyHash::Entry *e = propertyTable.lookup(id); - if (e && e->index < size) + if (e && e->index < size) { + Q_ASSERT(!propertyData.at(e->index).isEmpty()); return e->index == index; + } return false; } |