Rewrite QMap to use a RB tree
authorLars Knoll <lars.knoll@nokia.com>
Mon, 19 Mar 2012 19:53:20 +0000 (20:53 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 23 Mar 2012 08:31:09 +0000 (09:31 +0100)
commit5cb0368516abd293daf67711a36bbacc99422e9a
tree389b493f44b87c0f944081817ee3cfc4ebb420c8
parent3f7741fbe7ab4140f8f971c0cf88bb04e7feea6b
Rewrite QMap to use a RB tree

QMap used to use a skiplist in Qt 4.x, which has variable
sized nodes and we can thus not optimise using custom
allocators.

The rewrite now uses a red-black tree, and all allocations
and tree operations happen in the cpp file. This will allow
us to introduce custom allocation schemes in later versions
of Qt.

Added some more tests and a benchmark. Memory consumption
of the new QMap implementation is pretty much the same as before.
Performance of insertion and lookup has increased by 10-30%. iteration
is slower, but still extremely fast and should not matter compared
to the work usually done when iterating.

Change-Id: I8796c0e4b207d01111e2ead7ae55afb464dd88f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/io/qdatastream.h
src/corelib/tools/qmap.cpp
src/corelib/tools/qmap.h
tests/auto/corelib/tools/qmap/tst_qmap.cpp
tests/benchmarks/corelib/tools/qmap/main.cpp [new file with mode: 0644]
tests/benchmarks/corelib/tools/qmap/qmap.pro [new file with mode: 0644]
tests/benchmarks/corelib/tools/tools.pro