Skip to content

Commit

Permalink
Merge pull request #15574 from ethereum/optimize-optimizator
Browse files Browse the repository at this point in the history
Yul: Avoid expensive operations in functions called very often
  • Loading branch information
ekpyron authored Nov 20, 2024
2 parents 0a9cdf1 + 5150015 commit 4e954a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 6 additions & 1 deletion libyul/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,17 @@ void Parser::fetchDebugDataFromComment()
{
solAssert(m_sourceNames.has_value(), "");

std::string_view commentLiteral = m_scanner->currentCommentLiteral();
if (commentLiteral.empty())
{
m_astIDFromComment = std::nullopt;
return;
}
static std::regex const tagRegex = std::regex(
R"~~((?:^|\s+)(@[a-zA-Z0-9\-_]+)(?:\s+|$))~~", // tag, e.g: @src
std::regex_constants::ECMAScript | std::regex_constants::optimize
);

std::string_view commentLiteral = m_scanner->currentCommentLiteral();
std::match_results<std::string_view::const_iterator> match;

langutil::SourceLocation originLocation = m_locationFromComment;
Expand Down
5 changes: 2 additions & 3 deletions libyul/optimiser/SyntacticalEquality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ bool SyntacticallyEqual::expressionEqual(Identifier const& _lhs, Identifier cons
}
bool SyntacticallyEqual::expressionEqual(Literal const& _lhs, Literal const& _rhs)
{
yulAssert(validLiteral(_lhs), "Invalid lhs literal during syntactical equality check");
yulAssert(validLiteral(_rhs), "Invalid rhs literal during syntactical equality check");

assert(validLiteral(_lhs));
assert(validLiteral(_rhs));
return _lhs.value == _rhs.value;
}

Expand Down

0 comments on commit 4e954a3

Please sign in to comment.