Skip to content

Commit

Permalink
Yul: Avoid expensive check against std::regex when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
blishko committed Nov 20, 2024
1 parent 8548a93 commit 5150015
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 5150015

Please sign in to comment.