diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-02 12:59:51 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-02 12:59:51 (GMT) |
commit | c4ae87721e011fe44f301c4039f0651a05394162 (patch) | |
tree | c5e35a6360a7b93463ae627a8781a3b0ad138499 /src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h | |
parent | 6d71de4283c05b1b42ef26fe4c23334ad34c8a54 (diff) | |
download | Qt-c4ae87721e011fe44f301c4039f0651a05394162.zip Qt-c4ae87721e011fe44f301c4039f0651a05394162.tar.gz Qt-c4ae87721e011fe44f301c4039f0651a05394162.tar.bz2 |
Speedup item-lookup in Graphics View.
We don't have to do a stable sort anymore because the lessThan operator
now accounts for the insertion order. This also means we don't have to
sort all top-level items to preserve the insertion order in
QGraphicsScenePrivate::topLevelItemsInStackingOrder.
Reviewed-by: Andreas
Diffstat (limited to 'src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h')
-rw-r--r-- | src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h index 7b431e6..437b17d 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -173,21 +173,13 @@ inline bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item const QGraphicsItemPrivate *d2 = item2->d_ptr; bool f1 = d1->flags & QGraphicsItem::ItemStacksBehindParent; bool f2 = d2->flags & QGraphicsItem::ItemStacksBehindParent; - if (f1 != f2) return f2; - qreal z1 = d1->z; - qreal z2 = d2->z; - return z1 > z2; + if (f1 != f2) + return f2; + if (d1->z != d2->z) + return d1->z > d2->z; + return d1->siblingIndex > d2->siblingIndex; } -/*! - \internal -*/ -static inline bool qt_notclosestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2) -{ - return qt_closestLeaf(item2, item1); -} - - static inline bool QRectF_intersects(const QRectF &s, const QRectF &r) { qreal xp = s.left(); |