Pass YulString instead of std::string to Object::subObjectAt

This commit is contained in:
r0qs 2023-09-22 14:29:14 +02:00
parent 84d3af4a29
commit b5d4e1d685
No known key found for this signature in database
GPG Key ID: 61503DBA6667276C
3 changed files with 8 additions and 8 deletions

View File

@ -190,7 +190,7 @@ std::vector<size_t> Object::pathToSubObject(YulString _qualifiedName) const
return path; return path;
} }
Object const* Object::subObjectAt(std::string const& _qualifiedName) Object const* Object::subObjectAt(YulString _qualifiedName)
{ {
if (_qualifiedName.empty()) if (_qualifiedName.empty())
return nullptr; return nullptr;
@ -198,14 +198,14 @@ Object const* Object::subObjectAt(std::string const& _qualifiedName)
// If there is no `.` in the given `_qualifiedName`, the target // If there is no `.` in the given `_qualifiedName`, the target
// object name is considered to be the `_qualifiedName`, otherwise, // object name is considered to be the `_qualifiedName`, otherwise,
// the target object name is the last element in the path given by `_qualifiedName`. // the target object name is the last element in the path given by `_qualifiedName`.
std::string targetObjectName = _qualifiedName; YulString targetObjectName = _qualifiedName;
size_t targetObjectPos = _qualifiedName.find_last_of("."); size_t targetObjectPos = _qualifiedName.str().find_last_of(".");
if (targetObjectPos != std::string::npos) if (targetObjectPos != std::string::npos)
targetObjectName = _qualifiedName.substr(targetObjectPos + 1); targetObjectName = YulString(_qualifiedName.str().substr(targetObjectPos + 1));
Object const* foundObject = nullptr; Object const* foundObject = nullptr;
this->visitPath(YulString(_qualifiedName), [&](Object const* _subObject) -> bool { this->visitPath(_qualifiedName, [&](Object const* _subObject) -> bool {
if (targetObjectName != _subObject->name.str()) if (targetObjectName != _subObject->name)
return false; return false;
foundObject = _subObject; foundObject = _subObject;
return true; return true;

View File

@ -119,7 +119,7 @@ public:
/// Searches for a subobject at @param _qualifiedName within the current object. /// 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. /// @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 /// Visits all subobjects in the path given by the @a _qualifiedName
/// of the current object applying the function @a _visitor. /// of the current object applying the function @a _visitor.

View File

@ -253,7 +253,7 @@ public:
{ {
if (!m_inputIsCodeBlock) if (!m_inputIsCodeBlock)
{ {
Object const* subObject = m_object->subObjectAt(_objectPath); Object const* subObject = m_object->subObjectAt(YulString(_objectPath));
if (subObject == nullptr) if (subObject == nullptr)
solThrow(Exception, "Assembly object not found."); solThrow(Exception, "Assembly object not found.");