OSDN Git Service

use foreach() for iteration in QRasterWindowSurface::prepareBuffer()
authorIvailo Monev <xakepa10@gmail.com>
Mon, 12 Oct 2020 09:35:10 +0000 (12:35 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Mon, 12 Oct 2020 09:35:10 +0000 (12:35 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/painting/qwindowsurface_raster.cpp

index 2db3511..be8d670 100644 (file)
@@ -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<QRect> &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;