diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-02-27 14:34:46 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-02-28 19:07:11 +0000 |
commit | 9132d1516af99b3c0c132335756e7f2777ec5e78 (patch) | |
tree | 2338a896b4ff6ebad573768305cca138680bdcc2 /src/gui/painting/qregion.cpp | |
parent | 79cbff60dd8e1e1bbe922c0cf0dc65296e50a5c5 (diff) |
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) <ogoffart@woboq.com>
Diffstat (limited to 'src/gui/painting/qregion.cpp')
-rw-r--r-- | src/gui/painting/qregion.cpp | 23 |
1 files 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<QRect> myRects = rects(); - const QVector<QRect> otherRects = region.rects(); - - for (QVector<QRect>::const_iterator i1 = myRects.constBegin(); i1 < myRects.constEnd(); ++i1) - for (QVector<QRect>::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<QRect> rects = region.rects(); + auto rect = region.begin(); + const auto end = region.end(); QVarLengthArray<Segment> 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<QRect> myRects = rects(); - for (QVector<QRect>::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; } |