Use LazyInit for ContractDefinition::m_interfaceEvents

This commit is contained in:
Jason Cobb 2020-05-13 13:57:20 -04:00
parent 0e26700f65
commit 413fa92cee
No known key found for this signature in database
GPG Key ID: 2A3F6A6DCA1E8DED
2 changed files with 9 additions and 7 deletions

View File

@ -153,10 +153,10 @@ FunctionDefinition const* ContractDefinition::receiveFunction() const
vector<EventDefinition const*> const& ContractDefinition::interfaceEvents() const
{
if (!m_interfaceEvents)
{
return m_interfaceEvents.init([&]{
set<string> eventsSeen;
m_interfaceEvents = make_unique<vector<EventDefinition const*>>();
vector<EventDefinition const*> interfaceEvents;
for (ContractDefinition const* contract: annotation().linearizedBaseContracts)
for (EventDefinition const* e: contract->events())
{
@ -169,11 +169,12 @@ vector<EventDefinition const*> const& ContractDefinition::interfaceEvents() cons
if (eventsSeen.count(eventSignature) == 0)
{
eventsSeen.insert(eventSignature);
m_interfaceEvents->push_back(e);
interfaceEvents.push_back(e);
}
}
}
return *m_interfaceEvents;
return interfaceEvents;
});
}
vector<pair<util::FixedHash<4>, FunctionTypePointer>> const& ContractDefinition::interfaceFunctionList(bool _includeInheritedFunctions) const

View File

@ -31,6 +31,7 @@
#include <liblangutil/SourceLocation.h>
#include <libevmasm/Instruction.h>
#include <libsolutil/FixedHash.h>
#include <libsolutil/LazyInit.h>
#include <boost/noncopyable.hpp>
#include <json/json.h>
@ -530,7 +531,7 @@ private:
bool m_abstract{false};
mutable std::unique_ptr<std::vector<std::pair<util::FixedHash<4>, FunctionTypePointer>>> m_interfaceFunctionList[2];
mutable std::unique_ptr<std::vector<EventDefinition const*>> m_interfaceEvents;
util::LazyInit<std::vector<EventDefinition const*>> m_interfaceEvents;
};
class InheritanceSpecifier: public ASTNode