mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +00:00
LibJS: Lookahead for a period when parsing new.target
This allows us to skip saving and loading the state whenever we parse 'new'.
This commit is contained in:
parent
4d7e79fb72
commit
73eb29dabe
1 changed files with 5 additions and 3 deletions
|
@ -851,6 +851,10 @@ RefPtr<Statement> Parser::try_parse_labelled_statement(AllowLabelledFunction all
|
|||
|
||||
RefPtr<MetaProperty> Parser::try_parse_new_target_expression()
|
||||
{
|
||||
// Optimization which skips the save/load state.
|
||||
if (next_token().type() != TokenType::Period)
|
||||
return {};
|
||||
|
||||
save_state();
|
||||
auto rule_start = push_start();
|
||||
ArmedScopeGuard state_rollback_guard = [&] {
|
||||
|
@ -858,9 +862,7 @@ RefPtr<MetaProperty> Parser::try_parse_new_target_expression()
|
|||
};
|
||||
|
||||
consume(TokenType::New);
|
||||
if (!match(TokenType::Period))
|
||||
return {};
|
||||
consume();
|
||||
consume(TokenType::Period);
|
||||
if (!match(TokenType::Identifier))
|
||||
return {};
|
||||
// The string 'target' cannot have escapes so we check original value.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue