From 9df44b2b502f9ab9a379c8454b000d2085aed744 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 23 Sep 2018 11:35:54 +0200 Subject: 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 --- src/qml/jsruntime/qv4internalclass_p.h | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/qml/jsruntime/qv4internalclass_p.h') 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; } -- cgit v1.2.3