mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Restore efficient subobject search
This commit is contained in:
parent
98b5b6c916
commit
1ec239c63f
@ -33,7 +33,6 @@
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include <range/v3/algorithm/find_if.hpp>
|
||||
#include <range/v3/view/transform.hpp>
|
||||
|
||||
using namespace solidity;
|
||||
@ -53,6 +52,12 @@ std::string indent(std::string const& _input)
|
||||
|
||||
}
|
||||
|
||||
Object const* Object::at(YulString _name) const
|
||||
{
|
||||
size_t subIndex = this->subIndexByName.at(_name);
|
||||
return dynamic_cast<Object const*>(this->subObjects[subIndex].get());
|
||||
}
|
||||
|
||||
std::string Data::toString(Dialect const*, DebugInfoSelection const&, CharStreamProvider const*) const
|
||||
{
|
||||
return "data \"" + name.str() + "\" hex\"" + util::toHex(data) + "\"";
|
||||
@ -156,21 +161,14 @@ void Object::visitPath(YulString _qualifiedName, std::function<bool(Object const
|
||||
{
|
||||
yulAssert(!currentSubObjectName.empty(), "");
|
||||
|
||||
auto subObjectIt = ranges::find_if(
|
||||
object->subObjects,
|
||||
[¤tSubObjectName](auto const& _subObject) { return _subObject->name.str() == currentSubObjectName; }
|
||||
YulString subObjectName = YulString{currentSubObjectName};
|
||||
yulAssert(
|
||||
object->subIndexByName.count(subObjectName),
|
||||
"Assembly object not found or does not contain code."
|
||||
);
|
||||
|
||||
if (subObjectIt != object->subObjects.end())
|
||||
{
|
||||
object = dynamic_cast<Object const*>(subObjectIt->get());
|
||||
if (object)
|
||||
{
|
||||
yulAssert(object, "Assembly object <" + object->name.str() + "> not found or does not contain code.");
|
||||
if (_visitor(object))
|
||||
break;
|
||||
}
|
||||
}
|
||||
object = object->at(subObjectName);
|
||||
if (object && _visitor(object))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,6 +130,8 @@ public:
|
||||
std::function<bool(Object const*)> _visitor
|
||||
) const;
|
||||
|
||||
Object const* at(YulString _name) const;
|
||||
|
||||
/// sub id for object if it is subobject of another object, max value if it is not subobject
|
||||
size_t subId = std::numeric_limits<size_t>::max();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user