diff --git a/libyul/Object.cpp b/libyul/Object.cpp index 2c6ed0329..032e828bd 100644 --- a/libyul/Object.cpp +++ b/libyul/Object.cpp @@ -149,7 +149,7 @@ std::set Object::qualifiedDataNames() const return qualifiedNames; } -void Object::visitPath(YulString _qualifiedName, std::function _visitor) const +void Object::visitPath(YulString _qualifiedName, std::function const& _visitor) const { yulAssert(!_qualifiedName.empty(), ""); @@ -184,7 +184,7 @@ std::vector Object::pathToSubObject(YulString _qualifiedName) const this->visitPath(_qualifiedName, [&](Object const* _object) -> bool { yulAssert(_object->subId != std::numeric_limits::max(), ""); - path.push_back({_object->subId}); + path.push_back(_object->subId); return false; }); return path; @@ -205,12 +205,10 @@ Object const* Object::subObjectAt(std::string const& _qualifiedName) Object const* foundObject = nullptr; this->visitPath(YulString(_qualifiedName), [&](Object const* _subObject) -> bool { - if (targetObjectName == _subObject->name.str()) - { - foundObject = _subObject; - return true; - } - return false; + if (targetObjectName != _subObject->name.str()) + return false; + foundObject = _subObject; + return true; }); return foundObject; diff --git a/libyul/Object.h b/libyul/Object.h index ded9953ad..c9fd65826 100644 --- a/libyul/Object.h +++ b/libyul/Object.h @@ -127,7 +127,7 @@ public: /// it continues until the last subobject in the path is reached. void visitPath( YulString _qualifiedName, - std::function _visitor + std::function const& _visitor ) const; Object const* at(YulString _name) const;