mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Avoid creating copy of the object
This commit is contained in:
parent
61162deea7
commit
98b5b6c916
@ -192,9 +192,8 @@ std::vector<size_t> Object::pathToSubObject(YulString _qualifiedName) const
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Object> Object::subObjectAt(std::string const& _qualifiedName)
|
Object const* Object::subObjectAt(std::string const& _qualifiedName)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (_qualifiedName.empty())
|
if (_qualifiedName.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@ -206,11 +205,11 @@ std::shared_ptr<Object> Object::subObjectAt(std::string const& _qualifiedName)
|
|||||||
if (targetObjectPos != std::string::npos)
|
if (targetObjectPos != std::string::npos)
|
||||||
targetObjectName = _qualifiedName.substr(targetObjectPos + 1);
|
targetObjectName = _qualifiedName.substr(targetObjectPos + 1);
|
||||||
|
|
||||||
std::shared_ptr<Object> foundObject = nullptr;
|
Object const* foundObject = nullptr;
|
||||||
this->visitPath(YulString(_qualifiedName), [&](Object const* _subObject) -> bool {
|
this->visitPath(YulString(_qualifiedName), [&](Object const* _subObject) -> bool {
|
||||||
if (targetObjectName == _subObject->name.str())
|
if (targetObjectName == _subObject->name.str())
|
||||||
{
|
{
|
||||||
foundObject = std::make_shared<Object>(*_subObject);
|
foundObject = _subObject;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -118,8 +118,8 @@ public:
|
|||||||
std::vector<size_t> pathToSubObject(YulString _qualifiedName) const;
|
std::vector<size_t> pathToSubObject(YulString _qualifiedName) const;
|
||||||
|
|
||||||
/// Searches for a subobject at @param _qualifiedName within the current object.
|
/// Searches for a subobject at @param _qualifiedName within the current object.
|
||||||
/// @returns a shared_ptr 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.
|
||||||
std::shared_ptr<Object> subObjectAt(std::string const& _qualifiedName);
|
Object const* subObjectAt(std::string const& _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.
|
||||||
|
@ -253,7 +253,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (!m_inputIsCodeBlock)
|
if (!m_inputIsCodeBlock)
|
||||||
{
|
{
|
||||||
shared_ptr<Object> subObject = m_object->subObjectAt(_objectPath);
|
Object const* subObject = m_object->subObjectAt(_objectPath);
|
||||||
|
|
||||||
if (subObject == nullptr)
|
if (subObject == nullptr)
|
||||||
solThrow(Exception, "Assembly object not found.");
|
solThrow(Exception, "Assembly object not found.");
|
||||||
|
Loading…
Reference in New Issue
Block a user