mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:22:07 +00:00
LibJS: Avoid unnecessary lambda
Especially when it's evaluated immediately and unconditionally.
This commit is contained in:
parent
737c9f0a14
commit
db422fa499
1 changed files with 4 additions and 7 deletions
|
@ -263,10 +263,9 @@ NonnullRefPtr<Program> Parser::parse_program()
|
||||||
|
|
||||||
NonnullRefPtr<Statement> Parser::parse_statement()
|
NonnullRefPtr<Statement> Parser::parse_statement()
|
||||||
{
|
{
|
||||||
auto statement = [this]() -> NonnullRefPtr<Statement> {
|
|
||||||
switch (m_parser_state.m_current_token.type()) {
|
switch (m_parser_state.m_current_token.type()) {
|
||||||
case TokenType::Class:
|
case TokenType::Class:
|
||||||
return parse_class_declaration();
|
return parse_class_declaration();
|
||||||
case TokenType::Function: {
|
case TokenType::Function: {
|
||||||
auto declaration = parse_function_node<FunctionDeclaration>();
|
auto declaration = parse_function_node<FunctionDeclaration>();
|
||||||
m_parser_state.m_function_scopes.last().append(declaration);
|
m_parser_state.m_function_scopes.last().append(declaration);
|
||||||
|
@ -291,7 +290,7 @@ NonnullRefPtr<Statement> Parser::parse_statement()
|
||||||
case TokenType::Break:
|
case TokenType::Break:
|
||||||
return parse_break_statement();
|
return parse_break_statement();
|
||||||
case TokenType::Continue:
|
case TokenType::Continue:
|
||||||
return parse_continue_statement();
|
return parse_continue_statement();
|
||||||
case TokenType::Switch:
|
case TokenType::Switch:
|
||||||
return parse_switch_statement();
|
return parse_switch_statement();
|
||||||
case TokenType::Do:
|
case TokenType::Do:
|
||||||
|
@ -299,7 +298,7 @@ NonnullRefPtr<Statement> Parser::parse_statement()
|
||||||
case TokenType::While:
|
case TokenType::While:
|
||||||
return parse_while_statement();
|
return parse_while_statement();
|
||||||
case TokenType::Debugger:
|
case TokenType::Debugger:
|
||||||
return parse_debugger_statement();
|
return parse_debugger_statement();
|
||||||
case TokenType::Semicolon:
|
case TokenType::Semicolon:
|
||||||
consume();
|
consume();
|
||||||
return create_ast_node<EmptyStatement>();
|
return create_ast_node<EmptyStatement>();
|
||||||
|
@ -317,9 +316,7 @@ NonnullRefPtr<Statement> Parser::parse_statement()
|
||||||
expected("statement (missing switch case)");
|
expected("statement (missing switch case)");
|
||||||
consume();
|
consume();
|
||||||
return create_ast_node<ErrorStatement>();
|
return create_ast_node<ErrorStatement>();
|
||||||
} }();
|
}
|
||||||
|
|
||||||
return statement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expect_parens)
|
RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expect_parens)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue