From: Ivailo Monev Date: Mon, 12 Oct 2020 09:35:10 +0000 (+0300) Subject: use foreach() for iteration in QRasterWindowSurface::prepareBuffer() X-Git-Tag: 4.12.0~3491 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c9c32edef48fef202abbe7b5c77f2d350ba76048;p=kde%2FKatie.git use foreach() for iteration in QRasterWindowSurface::prepareBuffer() Signed-off-by: Ivailo Monev --- 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;