summaryrefslogtreecommitdiff
path: root/idlc
diff options
context:
space:
mode:
Diffstat (limited to 'idlc')
-rw-r--r--idlc/source/astenum.cxx13
-rw-r--r--idlc/source/astscope.cxx14
-rw-r--r--idlc/source/astservice.cxx24
3 files changed, 14 insertions, 37 deletions
diff --git a/idlc/source/astenum.cxx b/idlc/source/astenum.cxx
index 69fb0c7bfd89..4254f7264eaa 100644
--- a/idlc/source/astenum.cxx
+++ b/idlc/source/astenum.cxx
@@ -38,16 +38,11 @@ AstConstant* AstEnum::checkValue(AstExpression* pExpr)
DeclList::const_iterator iter = getIteratorBegin();
DeclList::const_iterator end = getIteratorEnd();
- while ( iter != end)
- {
- AstDeclaration* pDecl = *iter;
- AstConstant* pConst = static_cast<AstConstant*>(pDecl);
-
- if (pConst->getConstValue()->compareLong(pExpr))
- return pConst;
+ iter = std::find_if(iter, end, [&pExpr](AstDeclaration* pDecl) {
+ return static_cast<AstConstant*>(pDecl)->getConstValue()->compareLong(pExpr); });
- ++iter;
- }
+ if (iter != end)
+ return static_cast<AstConstant*>(*iter);
if ( pExpr->getExprValue()->u.lval > m_enumValueCount )
m_enumValueCount = pExpr->getExprValue()->u.lval + 1;
diff --git a/idlc/source/astscope.cxx b/idlc/source/astscope.cxx
index 1ddda3984458..9af691501a8a 100644
--- a/idlc/source/astscope.cxx
+++ b/idlc/source/astscope.cxx
@@ -85,18 +85,8 @@ AstDeclaration* AstScope::addDeclaration(AstDeclaration* pDecl)
sal_uInt16 AstScope::getNodeCount(NodeType nodeType) const
{
- DeclList::const_iterator iter = getIteratorBegin();
- DeclList::const_iterator end = getIteratorEnd();
- sal_uInt16 count = 0;
-
- while ( iter != end )
- {
- AstDeclaration* pDecl = *iter;
- if ( pDecl->getNodeType() == nodeType )
- count++;
- ++iter;
- }
- return count;
+ return static_cast<sal_uInt16>(std::count_if(getIteratorBegin(), getIteratorEnd(),
+ [&nodeType](const AstDeclaration* pDecl) { return pDecl->getNodeType() == nodeType; }));
}
AstDeclaration* AstScope::lookupByName(const OString& scopedName)
diff --git a/idlc/source/astservice.cxx b/idlc/source/astservice.cxx
index f92aa6ab94c4..c90ded6b4d7a 100644
--- a/idlc/source/astservice.cxx
+++ b/idlc/source/astservice.cxx
@@ -37,22 +37,14 @@ bool AstService::checkLastConstructor() const {
}
sal_uInt32 n = ctor->nMembers();
if (n == last->nMembers()) {
- for (DeclList::const_iterator i1(ctor->getIteratorBegin()),
- i2(last->getIteratorBegin());
- i1 != ctor->getIteratorEnd(); ++i1, ++i2)
- {
- sal_Int32 r1;
- AstDeclaration const * t1 = deconstructAndResolveTypedefs(
- static_cast< AstMember * >(*i1)->getType(), &r1);
- sal_Int32 r2;
- AstDeclaration const * t2 = deconstructAndResolveTypedefs(
- static_cast< AstMember * >(*i2)->getType(), &r2);
- if (r1 != r2 || t1->getScopedName() != t2->getScopedName())
- {
- return false;
- }
- }
- return true;
+ return std::equal(ctor->getIteratorBegin(), ctor->getIteratorEnd(), last->getIteratorBegin(),
+ [](AstDeclaration* a, AstDeclaration* b) {
+ sal_Int32 r1;
+ AstDeclaration const * t1 = deconstructAndResolveTypedefs(static_cast< AstMember * >(a)->getType(), &r1);
+ sal_Int32 r2;
+ AstDeclaration const * t2 = deconstructAndResolveTypedefs(static_cast< AstMember * >(b)->getType(), &r2);
+ return r1 == r2 && t1->getScopedName() == t2->getScopedName();
+ });
}
}
}