From efe8f9f8a054a7a7489db44e236e5424becf9db7 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Fri, 27 Feb 2015 11:35:25 +0100 Subject: Use lambda to avoid code duplication in inheritableMembers --- AST.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/AST.cpp b/AST.cpp index d18a296d..24a94a79 100644 --- a/AST.cpp +++ b/AST.cpp @@ -217,26 +217,23 @@ vector> const& ContractDefinition::getInheritableMembers m_inheritableMembers.reset(new vector>()); for (ContractDefinition const* contract: getLinearizedBaseContracts()) { - for (ASTPointer const& f: contract->getDefinedFunctions()) - if (memberSeen.count(f->getName()) == 0 && f->isVisibleInDerivedContracts()) + auto addInheritableMember = [&](ASTPointer const& _decl) + { + if (memberSeen.count(_decl->getName()) == 0 && _decl->isVisibleInDerivedContracts()) { - memberSeen.insert(f->getName()); - m_inheritableMembers->push_back(f); + memberSeen.insert(_decl->getName()); + m_inheritableMembers->push_back(_decl); } + }; + + for (ASTPointer const& f: contract->getDefinedFunctions()) + addInheritableMember(f); for (ASTPointer const& v: contract->getStateVariables()) - if (memberSeen.count(v->getName()) == 0 && v->isVisibleInDerivedContracts()) - { - memberSeen.insert(v->getName()); - m_inheritableMembers->push_back(v); - } + addInheritableMember(v); for (ASTPointer const& s: contract->getDefinedStructs()) - if (memberSeen.count(s->getName()) == 0 && s->isVisibleInDerivedContracts()) - { - memberSeen.insert(s->getName()); - m_inheritableMembers->push_back(s); - } + addInheritableMember(s); } } return *m_inheritableMembers; -- cgit v1.2.3