[Libreoffice-commits] core.git: basic/source
Arnaud Versini
arnaud.versini at gmail.com
Sun Dec 13 07:58:14 PST 2015
basic/source/basmgr/basicmanagerrepository.cxx | 4 ++--
basic/source/classes/sb.cxx | 4 +---
basic/source/classes/sbxmod.cxx | 10 ++++------
basic/source/comp/exprgen.cxx | 5 +----
basic/source/comp/exprnode.cxx | 5 ++---
basic/source/sbx/sbxarray.cxx | 19 ++++++++-----------
6 files changed, 18 insertions(+), 29 deletions(-)
New commits:
commit 4df183e2c9c548ecdd6f3421d9ef043194aa0981
Author: Arnaud Versini <arnaud.versini at gmail.com>
Date: Sun Dec 6 14:29:18 2015 +0100
BASIC: use c++ foreach loops when possible.
Change-Id: Ia1c734e26da88010eef40a4375c423b0765f43ae
Reviewed-on: https://gerrit.libreoffice.org/20423
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Arnaud Versini <arnaud.versini at libreoffice.org>
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx
index 1b3ca26..de559e9 100644
--- a/basic/source/basmgr/basicmanagerrepository.cxx
+++ b/basic/source/basmgr/basicmanagerrepository.cxx
@@ -427,10 +427,10 @@ namespace basic
{
// handle errors
std::vector<BasicError>& aErrors = _out_rpBasicManager->GetErrors();
- for(std::vector<BasicError>::const_iterator i = aErrors.begin(); i != aErrors.end(); ++i)
+ for(const auto& rError : aErrors)
{
// show message to user
- if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( i->GetErrorId() ) )
+ if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( rError.GetErrorId() ) )
{
// user wants to break loading of BASIC-manager
delete _out_rpBasicManager;
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index bfdfcef..a59da1e 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -1199,10 +1199,8 @@ void SbModule::implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassMod
StringVector& rReqTypes = pModule->pClassData->maRequiredTypes;
if( rReqTypes.size() > 0 )
{
- for( StringVector::iterator it = rReqTypes.begin() ; it != rReqTypes.end() ; ++it )
+ for( const auto& rStr : rReqTypes )
{
- OUString& rStr = *it;
-
// Is required type a class module?
ModuleInitDependencyMap::iterator itFind = rMap.find( rStr );
if( itFind != rMap.end() )
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 0730273..73428af 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1293,10 +1293,9 @@ void SbModule::RunInit()
void SbModule::AddVarName( const OUString& aName )
{
// see if the name is added already
- std::vector< OUString >::iterator it_end = mModuleVariableNames.end();
- for ( std::vector< OUString >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it )
+ for ( const auto& rModuleVariableName: mModuleVariableNames )
{
- if ( aName == *it )
+ if ( aName == rModuleVariableName )
return;
}
mModuleVariableNames.push_back( aName );
@@ -1304,13 +1303,12 @@ void SbModule::AddVarName( const OUString& aName )
void SbModule::RemoveVars()
{
- std::vector< OUString >::iterator it_end = mModuleVariableNames.end();
- for ( std::vector< OUString >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it )
+ for ( const auto& rModuleVariableName: mModuleVariableNames )
{
// We don't want a Find being called in a derived class ( e.g.
// SbUserform because it could trigger say an initialise event
// which would cause basic to be re-run in the middle of the init ( and remember RemoveVars is called from compile and we don't want code to run as part of the compile )
- SbxVariableRef p = SbModule::Find( *it, SbxCLASS_PROPERTY );
+ SbxVariableRef p = SbModule::Find( rModuleVariableName, SbxCLASS_PROPERTY );
if( p.Is() )
Remove (p);
}
diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx
index c1c74a0..ce6ff93 100644
--- a/basic/source/comp/exprgen.cxx
+++ b/basic/source/comp/exprgen.cxx
@@ -191,11 +191,8 @@ void SbiExprNode::GenElement( SbiCodeGen& rGen, SbiOpcode eOp )
if( aVar.pvMorePar )
{
- SbiExprListVector* pvMorePar = aVar.pvMorePar;
- SbiExprListVector::iterator it;
- for( it = pvMorePar->begin() ; it != pvMorePar->end() ; ++it )
+ for( auto& pExprList: *aVar.pvMorePar )
{
- SbiExprList* pExprList = *it;
pExprList->Gen();
rGen.Gen( _ARRAYACCESS );
}
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index 3bd9693..52c2211 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -111,9 +111,8 @@ SbiExprNode::~SbiExprNode()
SbiExprListVector* pvMorePar = aVar.pvMorePar;
if( pvMorePar )
{
- SbiExprListVector::iterator it;
- for( it = pvMorePar->begin() ; it != pvMorePar->end() ; ++it )
- delete *it;
+ for( const auto& pParam : *pvMorePar )
+ delete pParam;
delete pvMorePar;
}
}
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index ab44f57..2020485 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -60,18 +60,16 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray )
{
eType = rArray.eType;
Clear();
- VarEntriesType* pSrc = rArray.mpVarEntries;
- for( size_t i = 0; i < pSrc->size(); i++ )
+ for( const auto& rpSrcRef : *rArray.mpVarEntries )
{
- SbxVarEntry* pSrcRef = (*pSrc)[i];
- SbxVariableRef pSrc_ = pSrcRef->mpVar;
+ SbxVariableRef pSrc_ = rpSrcRef->mpVar;
if( !pSrc_ )
continue;
SbxVarEntry* pDstRef = new SbxVarEntry;
- pDstRef->mpVar = pSrcRef->mpVar;
+ pDstRef->mpVar = rpSrcRef->mpVar;
- if (pSrcRef->maAlias)
- pDstRef->maAlias.reset(*pSrcRef->maAlias);
+ if (rpSrcRef->maAlias)
+ pDstRef->maAlias.reset(*rpSrcRef->maAlias);
if( eType != SbxVARIANT )
{
@@ -666,15 +664,14 @@ bool SbxDimArray::GetDim( short n, short& rlb, short& rub ) const
sal_uInt32 SbxDimArray::Offset32( const sal_Int32* pIdx )
{
sal_uInt32 nPos = 0;
- for( std::vector<SbxDim>::const_iterator it = m_vDimensions.begin();
- it != m_vDimensions.end(); ++it )
+ for( const auto& rDimension : m_vDimensions )
{
sal_Int32 nIdx = *pIdx++;
- if( nIdx < it->nLbound || nIdx > it->nUbound )
+ if( nIdx < rDimension.nLbound || nIdx > rDimension.nUbound )
{
nPos = (sal_uInt32)SBX_MAXINDEX32 + 1; break;
}
- nPos = nPos * it->nSize + nIdx - it->nLbound;
+ nPos = nPos * rDimension.nSize + nIdx - rDimension.nLbound;
}
if( m_vDimensions.empty() || nPos > SBX_MAXINDEX32 )
{
More information about the Libreoffice-commits
mailing list