From 6952f867c6f506b89ca807fa986198f022ab0926 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Tue, 16 Jun 2009 09:48:05 +0200 Subject: Early exit from QRegion::intersects() if there is only one rect. Don't waste cycles with constructing a vector with rectangles if there is only one rectangle in the source region. Same as 36ff1b507bf2d509019ae8ddd638922b09755c6b, but for QRegion::intersects(QRect). Reviewed-by: bnilsen --- src/gui/painting/qregion.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 946d880..03e01c9 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -725,6 +725,8 @@ bool QRegion::intersects(const QRect &rect) const const QRect r = rect.normalized(); if (!rect_intersects(boundingRect(), r)) return false; + if (numRects() == 1) + return true; const QVector myRects = rects(); for (QVector::const_iterator it = myRects.constBegin(); it < myRects.constEnd(); ++it) -- cgit v0.12