emfio/source/reader/wmfreader.cxx | 4 ++-- vcl/source/bitmap/BitmapEx.cxx | 4 ++-- vcl/source/bitmap/BitmapShadowFilter.cxx | 4 ++-- vcl/source/bitmap/BitmapTools.cxx | 16 ++++++++-------- vcl/source/bitmap/bitmap.cxx | 2 +- vcl/source/filter/jpeg/JpegWriter.cxx | 2 +- vcl/source/filter/webp/reader.cxx | 14 +++++++------- vcl/source/filter/webp/writer.cxx | 8 ++++---- vcl/source/gdi/pdfwriter_impl.cxx | 8 ++++---- 9 files changed, 31 insertions(+), 31 deletions(-)
New commits: commit 07a3dd72f3eb79c03297aa9af9d77326b07458b6 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Apr 26 15:45:18 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Sat Apr 26 19:01:07 2025 +0200 no need to call Width/Height on every iteration of loop Change-Id: If4615e004ad78936cfbafcad66e78dd66051d32f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184664 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 5c16df6e42b2..d0774d5aad4c 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -1004,9 +1004,9 @@ namespace emfio if ( !aBmp.IsEmpty() ) { BitmapScopedReadAccess pBmp(aBmp); - for ( tools::Long y = 0; y < pBmp->Height(); y++ ) + for ( tools::Long y = 0, nHeight = pBmp->Height(); y < nHeight; y++ ) { - for ( tools::Long x = 0; x < pBmp->Width(); x++ ) + for ( tools::Long x = 0, nWidth = pBmp->Width(); x < nWidth; x++ ) { const BitmapColor aColor( pBmp->GetColor( y, x ) ); diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx index 63ac3d965b92..d32f6473a22a 100644 --- a/vcl/source/bitmap/BitmapEx.cxx +++ b/vcl/source/bitmap/BitmapEx.cxx @@ -1304,11 +1304,11 @@ void BitmapEx::ChangeColorAlpha( sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo ) if ( !(pReadAccess.get() && pAlphaWriteAccess.get()) ) return; - for ( tools::Long nY = 0; nY < pReadAccess->Height(); nY++ ) + for ( tools::Long nY = 0, nHeight = pReadAccess->Height(); nY < nHeight; nY++ ) { Scanline pScanline = pAlphaWriteAccess->GetScanline( nY ); Scanline pScanlineRead = pReadAccess->GetScanline( nY ); - for ( tools::Long nX = 0; nX < pReadAccess->Width(); nX++ ) + for ( tools::Long nX = 0, nWidth = pReadAccess->Width(); nX < nWidth; nX++ ) { const sal_uInt8 cIndex = pReadAccess->GetPixelFromData( pScanlineRead, nX ).GetIndex(); if ( cIndex == cIndexFrom ) diff --git a/vcl/source/bitmap/BitmapShadowFilter.cxx b/vcl/source/bitmap/BitmapShadowFilter.cxx index fd5c7ea45783..ce0e5c1ed0bd 100644 --- a/vcl/source/bitmap/BitmapShadowFilter.cxx +++ b/vcl/source/bitmap/BitmapShadowFilter.cxx @@ -20,11 +20,11 @@ BitmapEx BitmapShadowFilter::execute(BitmapEx const& rBitmapEx) const if (!pWriteAccess) return rBitmapEx; - for (sal_Int32 y(0); y < sal_Int32(pWriteAccess->Height()); y++) + for (sal_Int32 y(0), nHeight(pWriteAccess->Height()); y < nHeight; y++) { Scanline pScanline = pWriteAccess->GetScanline(y); - for (sal_Int32 x(0); x < sal_Int32(pWriteAccess->Width()); x++) + for (sal_Int32 x(0), nWidth(pWriteAccess->Width()); x < nWidth; x++) { const BitmapColor aColor = pWriteAccess->GetColor(y, x); sal_uInt16 nLuminance(static_cast<sal_uInt16>(aColor.GetLuminance()) + 1); diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx index 127458a5c28a..9c23507bcb8a 100644 --- a/vcl/source/bitmap/BitmapTools.cxx +++ b/vcl/source/bitmap/BitmapTools.cxx @@ -299,12 +299,12 @@ void fillWithData(sal_uInt8* pData, BitmapEx const& rBitmapEx) sal_uInt8* p = pData; - for (tools::Long y = 0; y < aReadAccessBitmap->Height(); ++y) + for (tools::Long y = 0, nHeight = aReadAccessBitmap->Height(); y < nHeight; ++y) { Scanline dataBitmap = aReadAccessBitmap->GetScanline(y); Scanline dataAlpha = aReadAccessAlpha ? aReadAccessAlpha->GetScanline(y) : nullptr; - for (tools::Long x = 0; x < aReadAccessBitmap->Width(); ++x) + for (tools::Long x = 0, nWidth = aReadAccessBitmap->Width(); x < nWidth; ++x) { BitmapColor aColor = aReadAccessBitmap->GetPixelFromData(dataBitmap, x); sal_uInt8 aAlpha = dataAlpha ? aReadAccessAlpha->GetPixelFromData(dataAlpha, x).GetBlue() : 255; @@ -564,10 +564,10 @@ void DrawAlphaBitmapAndAlphaGradient(BitmapEx & rBitmapEx, bool bFixedTransparen { const double fOpNew(1.0 - fTransparence); - for(tools::Long y(0); y < pOld->Height(); y++) + for(tools::Long y(0),nHeight(pOld->Height()); y < nHeight; y++) { Scanline pScanline = pOld->GetScanline( y ); - for(tools::Long x(0); x < pOld->Width(); x++) + for(tools::Long x(0),nWidth(pOld->Width()); x < nWidth; x++) { const double fOpOld(pOld->GetIndexFromData(pScanline, x) * fFactor); const sal_uInt8 aCol(basegfx::fround((fOpOld * fOpNew) * 255.0)); @@ -585,10 +585,10 @@ void DrawAlphaBitmapAndAlphaGradient(BitmapEx & rBitmapEx, bool bFixedTransparen assert(pOld->Width() == pNew->Width() && pOld->Height() == pNew->Height() && "Alpha masks have different sizes (!)"); - for(tools::Long y(0); y < pOld->Height(); y++) + for(tools::Long y(0),nHeight(pOld->Height()); y < nHeight; y++) { Scanline pScanline = pOld->GetScanline( y ); - for(tools::Long x(0); x < pOld->Width(); x++) + for(tools::Long x(0),nWidth(pOld->Width()); x < nWidth; x++) { const double fOpOld(pOld->GetIndexFromData(pScanline, x) * fFactor); const double fOpNew(pNew->GetIndexFromData(pScanline, x) * fFactor); @@ -1122,8 +1122,8 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, const Bitmap & aBitm BitmapScopedReadAccess access(aBitmap); o_rBack = access->GetColor(0,0); bool foundSecondColor = false;; - for(tools::Long y = 0; y < access->Height(); ++y) - for(tools::Long x = 0; x < access->Width(); ++x) + for(tools::Long y = 0, nHeight = access->Height(); y < nHeight; ++y) + for(tools::Long x = 0, nWidth = access->Width(); x < nWidth; ++x) { if(!foundSecondColor) { diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx index 4e7fdf67bdad..8d38e3b889c0 100644 --- a/vcl/source/bitmap/bitmap.cxx +++ b/vcl/source/bitmap/bitmap.cxx @@ -1358,7 +1358,7 @@ void Bitmap::AdaptBitCount(Bitmap& rNew) const static void shiftColors(sal_Int32* pColorArray, const BitmapScopedReadAccess& pReadAcc) { Scanline pScanlineRead = pReadAcc->GetScanline(0); // Why always 0? - for (tools::Long n = 0; n < pReadAcc->Width(); ++n) + for (tools::Long n = 0, nWidth = pReadAcc->Width(); n < nWidth; ++n) { const BitmapColor aColor = pReadAcc->GetColorFromData(pScanlineRead, n); *pColorArray++ = static_cast<sal_Int32>(aColor.GetBlue()) << 12; diff --git a/vcl/source/filter/jpeg/JpegWriter.cxx b/vcl/source/filter/jpeg/JpegWriter.cxx index 3a5776f8a6dc..bd7b5f392ae1 100644 --- a/vcl/source/filter/jpeg/JpegWriter.cxx +++ b/vcl/source/filter/jpeg/JpegWriter.cxx @@ -220,7 +220,7 @@ bool JPEGWriter::Write( const Graphic& rGraphic ) bool bIsGrey = true; tools::Long nWidth = mpReadAccess->Width(); - for ( tools::Long nY = 0; bIsGrey && ( nY < mpReadAccess->Height() ); nY++ ) + for ( tools::Long nY = 0, nHeight = mpReadAccess->Height(); bIsGrey && ( nY < nHeight ); nY++ ) { BitmapColor aColor; Scanline pScanlineRead = mpReadAccess->GetScanline( nY ); diff --git a/vcl/source/filter/webp/reader.cxx b/vcl/source/filter/webp/reader.cxx index cfc28a18440b..901974a92b9b 100644 --- a/vcl/source/filter/webp/reader.cxx +++ b/vcl/source/filter/webp/reader.cxx @@ -222,7 +222,7 @@ static bool readWebp(SvStream& stream, Graphic& graphic) std::vector<char> tmp; const sal_uInt32 lineSize = access->GetScanlineSize(); tmp.resize(lineSize); - for (tools::Long y = 0; y < access->Height() / 2; ++y) + for (tools::Long y = 0, nHeight = access->Height(); y < nHeight / 2; ++y) { tools::Long otherY = access->Height() - 1 - y; memcpy(tmp.data(), access->GetScanline(y), lineSize); @@ -236,12 +236,12 @@ static bool readWebp(SvStream& stream, Graphic& graphic) { // Split to normal and alpha bitmaps. BitmapScopedWriteAccess accessAlpha(bitmapAlpha); - for (tools::Long y = 0; y < access->Height(); ++y) + for (tools::Long y = 0, nHeight = access->Height(); y < nHeight; ++y) { const unsigned char* src = tmpRgbaData.data() + width * 4 * y; unsigned char* dstB = access->GetScanline(y); unsigned char* dstA = accessAlpha->GetScanline(y); - for (tools::Long x = 0; x < access->Width(); ++x) + for (tools::Long x = 0, nWidth = access->Width(); x < nWidth; ++x) { memcpy(dstB, src, 3); *dstA = *(src + 3); @@ -254,10 +254,10 @@ static bool readWebp(SvStream& stream, Graphic& graphic) } case PixelMode::SetPixel: { - for (tools::Long y = 0; y < access->Height(); ++y) + for (tools::Long y = 0, nHeight = access->Height(); y < nHeight; ++y) { const unsigned char* src = tmpRgbaData.data() + width * 4 * y; - for (tools::Long x = 0; x < access->Width(); ++x) + for (tools::Long x = 0, nWidth = access->Width(); x < nWidth; ++x) { sal_uInt8 r = src[0]; sal_uInt8 g = src[1]; @@ -270,10 +270,10 @@ static bool readWebp(SvStream& stream, Graphic& graphic) if (!bitmapAlpha.IsEmpty()) { BitmapScopedWriteAccess accessAlpha(bitmapAlpha); - for (tools::Long y = 0; y < accessAlpha->Height(); ++y) + for (tools::Long y = 0, nHeight = accessAlpha->Height(); y < nHeight; ++y) { const unsigned char* src = tmpRgbaData.data() + width * 4 * y; - for (tools::Long x = 0; x < accessAlpha->Width(); ++x) + for (tools::Long x = 0, nWidth = accessAlpha->Width(); x < nWidth; ++x) { sal_uInt8 a = src[3]; accessAlpha->SetPixelIndex(y, x, a); diff --git a/vcl/source/filter/webp/writer.cxx b/vcl/source/filter/webp/writer.cxx index cd63cd2d2786..f17b612a1198 100644 --- a/vcl/source/filter/webp/writer.cxx +++ b/vcl/source/filter/webp/writer.cxx @@ -140,12 +140,12 @@ static bool writeWebp(SvStream& rStream, const BitmapEx& bitmapEx, bool lossless data.resize(width * height * bpp); if (!bitmapAlpha.IsEmpty()) { - for (tools::Long y = 0; y < access->Height(); ++y) + for (tools::Long y = 0, nHeight = access->Height(); y < nHeight; ++y) { unsigned char* dst = data.data() + width * bpp * y; const sal_uInt8* srcB = access->GetScanline(y); const sal_uInt8* srcA = accessAlpha->GetScanline(y); - for (tools::Long x = 0; x < access->Width(); ++x) + for (tools::Long x = 0, nWidth = access->Width(); x < nWidth; ++x) { BitmapColor color = access->GetPixelFromData(srcB, x); BitmapColor alpha = accessAlpha->GetPixelFromData(srcA, x); @@ -160,11 +160,11 @@ static bool writeWebp(SvStream& rStream, const BitmapEx& bitmapEx, bool lossless } else { - for (tools::Long y = 0; y < access->Height(); ++y) + for (tools::Long y = 0, nHeight = access->Height(); y < nHeight; ++y) { unsigned char* dst = data.data() + width * bpp * y; const sal_uInt8* src = access->GetScanline(y); - for (tools::Long x = 0; x < access->Width(); ++x) + for (tools::Long x = 0, nWidth = access->Width(); x < nWidth; ++x) { Color color = access->GetPixelFromData(src, x); dst[0] = color.GetRed(); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 620b933d0bbe..a167743618a2 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -9748,7 +9748,7 @@ bool PDFWriterImpl::writeBitmapObject( const BitmapEmit& rObject ) //With PDF bitmaps, each row is padded to a BYTE boundary (multiple of 8 bits). const int nScanLineBytes = ((pAccess->GetBitCount() * pAccess->Width()) + 7U) / 8U; - for( tools::Long i = 0; i < pAccess->Height(); i++ ) + for( tools::Long i = 0, nHeight = pAccess->Height(); i < nHeight; i++ ) { if (!writeBufferBytes(pAccess->GetScanline(i), nScanLineBytes)) return false; @@ -9758,9 +9758,9 @@ bool PDFWriterImpl::writeBitmapObject( const BitmapEmit& rObject ) { const int nScanLineBytes = pAccess->Width()*3; std::unique_ptr<sal_uInt8[]> xCol(new sal_uInt8[nScanLineBytes]); - for( tools::Long y = 0; y < pAccess->Height(); y++ ) + for( tools::Long y = 0, nHeight = pAccess->Height(); y < nHeight; y++ ) { - for( tools::Long x = 0; x < pAccess->Width(); x++ ) + for( tools::Long x = 0, nWidth = pAccess->Width(); x < nWidth; x++ ) { BitmapColor aColor = pAccess->GetColor( y, x ); xCol[3*x+0] = aColor.GetRed(); @@ -9856,7 +9856,7 @@ bool PDFWriterImpl::writeBitmapMaskObject( sal_Int32 nMaskObject, const AlphaMas const int nScanLineBytes = ((pAccess->GetBitCount() * pAccess->Width()) + 7U) / 8U; // we have alpha, but we want to output transparency, so we need to invert the data std::unique_ptr<sal_uInt8[]> pInvertedBytes = std::make_unique<sal_uInt8[]>(nScanLineBytes); - for( tools::Long i = 0; i < pAccess->Height(); i++ ) + for( tools::Long i = 0, nHeight = pAccess->Height(); i < nHeight; i++ ) { const Scanline pScanline = pAccess->GetScanline(i); std::copy(pScanline, pScanline + nScanLineBytes, pInvertedBytes.get());