mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibJS: Don't create unique FunctionParameters for every empty param set
This commit is contained in:
parent
72aa90312a
commit
d3e8fbd9cd
Notes:
github-actions[bot]
2025-11-09 11:15:51 +00:00
Author: https://github.com/awesomekling
Commit: d3e8fbd9cd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6764
1 changed files with 4 additions and 0 deletions
|
|
@ -3139,6 +3139,10 @@ NonnullRefPtr<FunctionParameters const> Parser::parse_formal_parameters(int& fun
|
|||
if (!match(TokenType::Eof) && !match(TokenType::ParenClose))
|
||||
expected(Token::name(TokenType::ParenClose));
|
||||
|
||||
// OPTIMIZATION: If there are no parameters, return the shared empty FunctionParameters instance.
|
||||
if (parameters.is_empty())
|
||||
return FunctionParameters::empty();
|
||||
|
||||
parameters.shrink_to_fit();
|
||||
return FunctionParameters::create(move(parameters));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue