diff options
author | Robin Burchell <robin.burchell@viroteck.net> | 2015-01-08 01:28:58 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2015-01-09 11:51:28 +0100 |
commit | 6421f275286b3238fe1a7a5e909225251f3e8dbf (patch) | |
tree | e91388f7e70d3d2c4d3542701bb573988b7a5a10 /src/qml/jsruntime/qv4internalclass_p.h | |
parent | 2a375c3f54da8bbf637880ea89f4e7e9937bdb26 (diff) |
Replace InternalClass transitions hash with a sorted vector.
In a reasonable test application, there were some 1697 transition entries. Out
of these, 1663 of them had only a single item. The remainder, with the exception
of three, had <10 items. Only one of these had a count of >50 items (86).
As can be seen, most of the time, transitions is usually quite sparsely
populated, so using a hash is a large amount of overhead considering there's
just a few elements. For the times when it isn't, the vector being sorted
should help take care of that.
Since transitions are never removed, we can use a similar trick to
ba690fb73864915b4a35bbec5b7dc134ff1dafd0 and use a sorted vector to store them.
Compared to the hash approach, this saved ~412kb according to malloc_stats on a
reasonably comprehensive test application. Coincidentally, this also improved
v8bench for me by ~10%.
Note that this undoes 132cdfa69cae45d0c02ea715ce58722bbcd57e73, but the
expectation is that the fewer allocations done by using a vector will outweigh
the need to reserve any specific allocation initially.
Change-Id: Iec57a7db7e9a60347c9683b1cb1598f6d9c866f7
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4internalclass_p.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h index 4367f6576d..5973ca2c7c 100644 --- a/src/qml/jsruntime/qv4internalclass_p.h +++ b/src/qml/jsruntime/qv4internalclass_p.h @@ -193,6 +193,7 @@ struct InternalClassTransition Identifier *id; const ManagedVTable *vtable; }; + InternalClass *lookup; int flags; enum { // range 0-0xff is reserved for attribute changes @@ -201,8 +202,10 @@ struct InternalClassTransition bool operator==(const InternalClassTransition &other) const { return id == other.id && flags == other.flags; } + + bool operator<(const InternalClassTransition &other) const + { return id < other.id; } }; -uint qHash(const QV4::InternalClassTransition &t, uint = 0); struct InternalClass : public QQmlJS::Managed { ExecutionEngine *engine; @@ -213,7 +216,8 @@ struct InternalClass : public QQmlJS::Managed { SharedInternalClassData<PropertyAttributes> propertyData; typedef InternalClassTransition Transition; - QHash<Transition, InternalClass *> transitions; // id to next class, positive means add, negative delete + std::vector<Transition> transitions; + InternalClassTransition &lookupOrInsertTransition(const InternalClassTransition &t); InternalClass *m_sealed; InternalClass *m_frozen; |