tdf#145538: Prefer range-based for in svtools, Sfx2, DDE client

Replace a few index loops with range-based iteration where the counter
was only used for element access: index algorithm lookup, UTF-16 OLE
string streaming, and scanning DDE connections for a matching handle.

Verification: make svtools sfx2
Change-Id: I5678af4bdab855d7ce60bdccc46f608cee56c4e8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204657
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
Muhammad Naeem
2026-05-09 11:49:37 +02:00
committed by Julien Nabet
parent 3f11b4bb09
commit 01144d08d9
3 changed files with 10 additions and 9 deletions
+2 -2
View File
@@ -326,8 +326,8 @@ void SfxOleStringHelper::ImplSaveString16( SvStream& rStrm, std::u16string_view
sal_Int32 nSize = static_cast< sal_Int32 >( rValue.size() + 1 );
rStrm.WriteInt32( nSize );
// write character array with trailing NUL character
for( size_t nIdx = 0; nIdx < rValue.size(); ++nIdx )
rStrm.WriteUInt16( rValue[ nIdx ] );
for( char16_t c : rValue )
rStrm.WriteUInt16( c );
rStrm.WriteUInt16( 0 );
// stream is always padded to 32-bit boundary, add 2 bytes on odd character count
if( (nSize & 1) == 1 )
+5 -4
View File
@@ -51,12 +51,13 @@ HDDEDATA CALLBACK DdeInternal::CliCallback( UINT nCode, UINT nCbType,
const DdeInstData& rInst = ImpGetInstData();
for ( size_t i = 0; i < rAll.size(); ++i)
for ( DdeConnection* pConn : rAll )
{
self = rAll[i];
if ( self->pImp->hConv == hConv )
if ( pConn->pImp->hConv == hConv )
{
self = pConn;
break;
}
}
if( self )
+3 -3
View File
@@ -49,9 +49,9 @@ const OUString& IndexEntryResource::GetTranslation(const OUString &r_Algorithm)
aLocaleFreeAlgorithm = r_Algorithm.copy(nIndex);
}
for (size_t i = 0; i < m_aData.size(); ++i)
if (aLocaleFreeAlgorithm == m_aData[i].GetAlgorithm())
return m_aData[i].GetTranslation();
for (const auto& rData : m_aData)
if (aLocaleFreeAlgorithm == rData.GetAlgorithm())
return rData.GetTranslation();
return r_Algorithm;
}