mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-29 02:57:17 +02:00
LibJS: Shrink DeclarativeEnvironment bindings vector to fit
After setting up all the bindings in function_declaration_instantiation, we now ask DeclarativeEnvironment to do a shrink_to_fit() on its vector of bindings. This ends up saving 5.6 MiB on twitter.com/awesomekling :^)
This commit is contained in:
committed by
Linus Groh
parent
d77ce7bae9
commit
2e98c17347
Notes:
sideshowbarker
2024-07-17 03:36:30 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2e98c17347 Pull-request: https://github.com/SerenityOS/serenity/pull/16215 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/trflynn89
@@ -577,6 +577,11 @@ ThrowCompletionOr<void> ECMAScriptFunctionObject::function_declaration_instantia
|
||||
MUST(var_environment->set_mutable_binding(vm, declaration.name(), function, false));
|
||||
}
|
||||
|
||||
if (is<DeclarativeEnvironment>(*lex_environment))
|
||||
static_cast<DeclarativeEnvironment*>(lex_environment)->shrink_to_fit();
|
||||
if (is<DeclarativeEnvironment>(*var_environment))
|
||||
static_cast<DeclarativeEnvironment*>(var_environment)->shrink_to_fit();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user