Only count variables if only variables are needed.

This commit is contained in:
chriseth
2022-11-14 10:24:28 +01:00
parent 310a58dd31
commit f1febf69d0
7 changed files with 74 additions and 31 deletions
+3 -4
View File
@@ -668,10 +668,9 @@ bool statementNeedsReturnVariableSetup(Statement const& _statement, vector<Typed
holds_alternative<Assignment>(_statement)
)
{
ReferencesCounter referencesCounter{ReferencesCounter::CountWhat::OnlyVariables};
referencesCounter.visit(_statement);
auto isReferenced = [&referencesCounter](TypedName const& _returnVariable) {
return referencesCounter.references().count(_returnVariable.name);
map<YulString, size_t> references = VariableReferencesCounter::countReferences(_statement);
auto isReferenced = [&references](TypedName const& _returnVariable) {
return references.count(_returnVariable.name);
};
if (ranges::none_of(_returnVariables, isReferenced))
return false;