Replace InternalClass transitions hash with a sorted vector.
authorRobin Burchell <robin.burchell@viroteck.net>
Thu, 8 Jan 2015 00:28:58 +0000 (01:28 +0100)
committerLars Knoll <lars.knoll@digia.com>
Fri, 9 Jan 2015 10:51:28 +0000 (11:51 +0100)
commit6421f275286b3238fe1a7a5e909225251f3e8dbf
treee91388f7e70d3d2c4d3542701bb573988b7a5a10
parent2a375c3f54da8bbf637880ea89f4e7e9937bdb26
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>
src/qml/jsruntime/qv4internalclass.cpp
src/qml/jsruntime/qv4internalclass_p.h