summaryrefslogtreecommitdiffstats
path: root/basctl
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-03-13 21:11:09 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-03-16 20:16:46 +0100
commit10a48c737d347bcce765c8fbe009bc1dd0bb0c4d (patch)
tree6688e9ca36964bcbf589e60452a331b49a81bfde /basctl
parenttdf#45904 Move XNameReplace Java test to C++ (diff)
downloadcore-10a48c737d347bcce765c8fbe009bc1dd0bb0c4d.tar.gz
core-10a48c737d347bcce765c8fbe009bc1dd0bb0c4d.zip
Simplify containers iterations in basctl, basegfx, basic, bridges
Use range-based loop or replace with STL functions Change-Id: I8594740103bdc2091c2d03d4b92bbe8393f5378c Reviewed-on: https://gerrit.libreoffice.org/69223 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2b.cxx29
-rw-r--r--basctl/source/basicide/bastypes.cxx6
-rw-r--r--basctl/source/basicide/breakpoint.cxx25
3 files changed, 15 insertions, 45 deletions
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index e1d526df52cf..728ac019d167 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -2877,32 +2877,9 @@ UnoTypeCodeCompletetor::UnoTypeCodeCompletetor( const std::vector< OUString >& a
return;
}
- auto j = aVect.begin() + 1;//start from aVect[1]: aVect[0] is the variable name
- OUString sMethName;
-
- while( j != aVect.end() )
- {
- sMethName = *j;
-
- if( CodeCompleteOptions::IsExtendedTypeDeclaration() )
- {
- if( !CheckMethod(sMethName) && !CheckField(sMethName) )
- {
- bCanComplete = false;
- break;
- }
- }
- else
- {
- if( !CheckField(sMethName) )
- {
- bCanComplete = false;
- break;
- }
- }
-
- ++j;
- }
+ //start from aVect[1]: aVect[0] is the variable name
+ bCanComplete = std::none_of(aVect.begin() + 1, aVect.end(), [this](const OUString& rMethName) {
+ return (!CodeCompleteOptions::IsExtendedTypeDeclaration() || !CheckMethod(rMethName)) && !CheckField(rMethName); });
}
std::vector< OUString > UnoTypeCodeCompletetor::GetXIdlClassMethods() const
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx
index 5ffbfbfd302d..169ee1818bdf 100644
--- a/basctl/source/basicide/bastypes.cxx
+++ b/basctl/source/basicide/bastypes.cxx
@@ -664,10 +664,8 @@ void LibInfo::InsertInfo (
void LibInfo::RemoveInfoFor (ScriptDocument const& rDocument)
{
- Map::iterator it;
- for (it = m_aMap.begin(); it != m_aMap.end(); ++it)
- if (it->first.GetDocument() == rDocument)
- break;
+ Map::iterator it = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [&rDocument](Map::reference rEntry) { return rEntry.first.GetDocument() == rDocument; });
if (it != m_aMap.end())
m_aMap.erase(it);
}
diff --git a/basctl/source/basicide/breakpoint.cxx b/basctl/source/basicide/breakpoint.cxx
index 15d5139f6610..b70be0594579 100644
--- a/basctl/source/basicide/breakpoint.cxx
+++ b/basctl/source/basicide/breakpoint.cxx
@@ -51,14 +51,13 @@ void BreakPointList::transfer(BreakPointList & rList)
void BreakPointList::InsertSorted(BreakPoint aNewBrk)
{
- for ( auto it = maBreakPoints.begin(); it != maBreakPoints.end(); ++it )
+ auto it = std::find_if(maBreakPoints.begin(), maBreakPoints.end(),
+ [&aNewBrk](const BreakPoint& rBreakPoint) { return aNewBrk.nLine <= rBreakPoint.nLine; });
+ if (it != maBreakPoints.end())
{
- if ( aNewBrk.nLine <= it->nLine )
- {
- DBG_ASSERT( it->nLine != aNewBrk.nLine, "BreakPoint exists already!" );
- maBreakPoints.insert( it, aNewBrk );
- return;
- }
+ DBG_ASSERT( it->nLine != aNewBrk.nLine, "BreakPoint exists already!" );
+ maBreakPoints.insert( it, aNewBrk );
+ return;
}
// no insert position found => LIST_APPEND
maBreakPoints.push_back( aNewBrk );
@@ -127,14 +126,10 @@ void BreakPointList::ResetHitCount()
void BreakPointList::remove(const BreakPoint* ptr)
{
- for ( auto i = maBreakPoints.begin(); i != maBreakPoints.end(); ++i )
- {
- if ( ptr == &(*i) )
- {
- maBreakPoints.erase( i );
- return;
- }
- }
+ auto i = std::find_if(maBreakPoints.begin(), maBreakPoints.end(),
+ [&ptr](const BreakPoint& rBreakPoint) { return ptr == &rBreakPoint; });
+ if (i != maBreakPoints.end())
+ maBreakPoints.erase( i );
return;
}