From 9132d1516af99b3c0c132335756e7f2777ec5e78 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 27 Feb 2016 14:34:46 +0100 Subject: QRegion: use new begin()/end() instead of rect() Saves ~100b in text size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: If2bbd2baac6f4ab66ad436028a8013ce0fa97a33 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/painting/qregion.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 2068026ca9..b70257a00f 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -723,12 +723,9 @@ bool QRegion::intersects(const QRegion ®ion) const if (rectCount() == 1 && region.rectCount() == 1) return true; - const QVector myRects = rects(); - const QVector otherRects = region.rects(); - - for (QVector::const_iterator i1 = myRects.constBegin(); i1 < myRects.constEnd(); ++i1) - for (QVector::const_iterator i2 = otherRects.constBegin(); i2 < otherRects.constEnd(); ++i2) - if (rect_intersects(*i1, *i2)) + for (const QRect &myRect : *this) + for (const QRect &otherRect : region) + if (rect_intersects(myRect, otherRect)) return true; return false; } @@ -1152,13 +1149,11 @@ Q_GUI_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion) return result; } - const QVector rects = region.rects(); + auto rect = region.begin(); + const auto end = region.end(); QVarLengthArray segments; - segments.resize(4 * rects.size()); - - const QRect *rect = rects.constData(); - const QRect *end = rect + rects.size(); + segments.resize(4 * (end - rect)); int lastRowSegmentCount = 0; Segment *lastRowSegments = 0; @@ -4421,10 +4416,10 @@ bool QRegion::intersects(const QRect &rect) const if (d->qt_rgn->numRects == 1) return true; - const QVector myRects = rects(); - for (QVector::const_iterator it = myRects.constBegin(); it < myRects.constEnd(); ++it) - if (rect_intersects(r, *it)) + for (const QRect &rect : *this) { + if (rect_intersects(r, rect)) return true; + } return false; } -- cgit v1.2.3