summaryrefslogtreecommitdiffstats
path: root/config.tests
diff options
context:
space:
mode:
authorDimitar Asenov <dimitar.asenov@gmail.com>2014-06-07 03:53:51 -0700
committerIsmo Haataja <ismo.haataja@digia.com>2014-06-16 09:58:58 +0200
commitbf2ec0183cb62034f2a4e700b7ab741371fcb106 (patch)
tree9a5e9d4e3f4485e23d8d034f52f530e6cb79a21d /config.tests
parent4e7baaaa91ce663b0b5c315e5b049d1574aef73f (diff)
Speed up the removal of items from a QGraphicsScene
When using a linear index, all items in a scene are stored in a QList. While adding new items is a constant operation, removal requires a traversal through the entire list. This is especially problematic when the scene contains millions of items and many of them are removed, which requires a linear search for each item, resulting in a very slow operation. Moreover, this behavior is actually inconsistent with the current documentation which states for the linear index: "Adding, moving and removing items, however, is done in constant time." Instead of removing items from the list in the index, this patch just marks the list as invalid. The next time the list is required it will be rebuilt from scratch by traversing all items from the scene. This new behavior more accurately matches the documentation. Testing this change in a scene with over 1 million objects, resulted in a massive speed up, effectively eliminating the overhead of item removal. [ChangeLog][QtWidgets][QGraphicsScene] Speed up the removal of items when using the linear index. Change-Id: I95c7b90b9f1fe426018695b6429138530e6d2f3e Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name>
Diffstat (limited to 'config.tests')
0 files changed, 0 insertions, 0 deletions