diff --git a/libyul/Object.cpp b/libyul/Object.cpp index 032e828bd..12b964e80 100644 --- a/libyul/Object.cpp +++ b/libyul/Object.cpp @@ -190,7 +190,7 @@ std::vector Object::pathToSubObject(YulString _qualifiedName) const return path; } -Object const* Object::subObjectAt(std::string const& _qualifiedName) +Object const* Object::subObjectAt(YulString _qualifiedName) { if (_qualifiedName.empty()) return nullptr; @@ -198,14 +198,14 @@ Object const* Object::subObjectAt(std::string const& _qualifiedName) // If there is no `.` in the given `_qualifiedName`, the target // object name is considered to be the `_qualifiedName`, otherwise, // the target object name is the last element in the path given by `_qualifiedName`. - std::string targetObjectName = _qualifiedName; - size_t targetObjectPos = _qualifiedName.find_last_of("."); + YulString targetObjectName = _qualifiedName; + size_t targetObjectPos = _qualifiedName.str().find_last_of("."); if (targetObjectPos != std::string::npos) - targetObjectName = _qualifiedName.substr(targetObjectPos + 1); + targetObjectName = YulString(_qualifiedName.str().substr(targetObjectPos + 1)); Object const* foundObject = nullptr; - this->visitPath(YulString(_qualifiedName), [&](Object const* _subObject) -> bool { - if (targetObjectName != _subObject->name.str()) + this->visitPath(_qualifiedName, [&](Object const* _subObject) -> bool { + if (targetObjectName != _subObject->name) return false; foundObject = _subObject; return true; diff --git a/libyul/Object.h b/libyul/Object.h index c9fd65826..4a97870a5 100644 --- a/libyul/Object.h +++ b/libyul/Object.h @@ -119,7 +119,7 @@ public: /// Searches for a subobject at @param _qualifiedName within the current object. /// @returns a pointer to the subobject or a nullptr if it was not found. - Object const* subObjectAt(std::string const& _qualifiedName); + Object const* subObjectAt(YulString _qualifiedName); /// Visits all subobjects in the path given by the @a _qualifiedName /// of the current object applying the function @a _visitor. diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index b8bba823d..300d9d940 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -253,7 +253,7 @@ public: { if (!m_inputIsCodeBlock) { - Object const* subObject = m_object->subObjectAt(_objectPath); + Object const* subObject = m_object->subObjectAt(YulString(_objectPath)); if (subObject == nullptr) solThrow(Exception, "Assembly object not found.");