1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:37:36 +00:00

LibJS: Pre-calculate the number of bindings for function environments

We can use `ensure_capacity` for binding vectors if we know their sizes
in advance. This ensures that binding vectors aren't reallocated during
the `function_declaration_instantiation` execution.

With this change, `try_grow_capacity()` and `shrink_to_fit()` are no
longer visible in the `function_declaration_instantiation()` profiles
when running React-Redux-TodoMVC from Speedometer.
This commit is contained in:
Aliaksandr Kalenik 2023-09-20 01:32:07 +02:00 committed by Andreas Kling
parent 98f479318a
commit 42e9dfedc2
3 changed files with 78 additions and 0 deletions

View file

@ -60,6 +60,11 @@ public:
void shrink_to_fit();
void ensure_capacity(size_t needed_capacity)
{
m_bindings.ensure_capacity(needed_capacity);
}
[[nodiscard]] u64 environment_serial_number() const { return m_environment_serial_number; }
private: