path: root/src/plugins/platforms/directfb
diff options
authorDimitar Asenov <>2014-09-02 14:15:27 +0200
committerDimitar Asenov <>2014-09-03 16:52:17 +0200
commit633647334c14b263a0fcc7a5087bf1e2ea3e212a (patch)
tree469fa44953a46c084487b203dde9cd64c86ec069 /src/plugins/platforms/directfb
parent5b2f77c59839b3d110ca4bf7007e4d5ba513b078 (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." With this change, the list is sorted once an item needs to be removed. The item to be removed is then found using binary search. To reduce the overhead of sorting the list is not sorted from scratch. First the newly inserted items are sorted and then the two parts of the list are merged. [ChangeLog][QtWidgets][QGraphicsScene] Speed up the removal of items when using the linear index. Change-Id: I28708622605d7fb0fac656df1f9b2f2fa3136759 Reviewed-by: Andreas Aardal Hanssen <>
Diffstat (limited to 'src/plugins/platforms/directfb')
0 files changed, 0 insertions, 0 deletions