summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-16 07:48:05 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-16 07:48:05 (GMT)
commit6952f867c6f506b89ca807fa986198f022ab0926 (patch)
treedad155ec12e25df71edfd7c0dd4be2b5813217aa /src
parent36ff1b507bf2d509019ae8ddd638922b09755c6b (diff)
downloadQt-6952f867c6f506b89ca807fa986198f022ab0926.zip
Qt-6952f867c6f506b89ca807fa986198f022ab0926.tar.gz
Qt-6952f867c6f506b89ca807fa986198f022ab0926.tar.bz2
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
Diffstat (limited to 'src')
-rw-r--r--src/gui/painting/qregion.cpp2
1 files changed, 2 insertions, 0 deletions
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<QRect> myRects = rects();
for (QVector<QRect>::const_iterator it = myRects.constBegin(); it < myRects.constEnd(); ++it)