summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-07 14:02:37 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-07 14:49:21 +0100
commitff60e8ffc6e940bcf71cc1a5a697d1b2c25c6caa (patch)
tree595d2ed9e87231754a5659ce4489c5b4162cd744 /Userland/Utilities
parent2dad3dca9a133d8b1ca301271a73d45b5c1c370e (diff)
downloadserenity-ff60e8ffc6e940bcf71cc1a5a697d1b2c25c6caa.zip
LibJS: Use Vector instead of HashMap in DeclarativeEnvironment
Constructing the HashMap in DeclarativeEnvironment was by far the most expensive thing when making JavaScript function calls. As it turns out, we don't really need this to be a HashMap in the first place, as lookups are cached (by EnvironmentCoordinate) after the first access, so after that we were not even looking in the HashMap, going directly to the bindings Vector instead. This reduces function_declaration_instantiation() from 16% to 9% when idling in "Biolab Disaster". It also reduces has_binding() from 3% to 1% on the same content. With these changes, we now actually get to idle a little bit between game frames on my machine. :^)
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/js.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp
index 6672cd01fa..c9ec2e29b5 100644
--- a/Userland/Utilities/js.cpp
+++ b/Userland/Utilities/js.cpp
@@ -1612,7 +1612,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto const& variable = interpreter->global_object();
list_all_properties(variable.shape(), variable_name);
- for (String& name : global_environment.declarative_record().bindings()) {
+ for (auto const& name : global_environment.declarative_record().bindings()) {
if (name.starts_with(variable_name)) {
results.empend(name);
results.last().invariant_offset = variable_name.length();