From c9c32edef48fef202abbe7b5c77f2d350ba76048 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 12 Oct 2020 12:35:10 +0300 Subject: [PATCH] use foreach() for iteration in QRasterWindowSurface::prepareBuffer() Signed-off-by: Ivailo Monev --- src/gui/painting/qwindowsurface_raster.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index 2db35112a..be8d670c4 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -229,29 +229,24 @@ void QRasterWindowSurface::prepareBuffer(QImage::Format format) QRegion staticRegion(staticContents()); // Make sure we're inside the boundaries of the old image. staticRegion &= QRect(0, 0, oldImage->width(), oldImage->height()); - const QVector &rects = staticRegion.rects(); - const QRect *srcRect = rects.constData(); // Copy the static content of the old image into the new one. - int numRectsLeft = rects.size(); - do { - const int bytesOffset = srcRect->x() * bytesPerPixel; - const int dy = srcRect->y(); + foreach(const QRect &srcRect, staticRegion.rects()) { + const int bytesOffset = srcRect.x() * bytesPerPixel; + const int dy = srcRect.y(); // Adjust src and dst to point to the right offset. const uchar *s = src + dy * srcBytesPerLine + bytesOffset; uchar *d = dst + dy * dstBytesPerLine + bytesOffset; - const int numBytes = srcRect->width() * bytesPerPixel; + const int numBytes = srcRect.width() * bytesPerPixel; - int numScanLinesLeft = srcRect->height(); + int numScanLinesLeft = srcRect.height(); do { ::memcpy(d, s, numBytes); d += dstBytesPerLine; s += srcBytesPerLine; } while (--numScanLinesLeft); - - ++srcRect; - } while (--numRectsLeft); + }; } delete oldImage; -- 2.11.0