1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:27:43 +00:00

LibJS: Call shrink_to_fit() on various Vectors created during parse

Vectors that stick around in the AST were wasting a fair bit of memory
due to the growth padding we keep by default. This patch goes after some
of these vectors with the shrink_to_fit() stick to reduce waste.

Since the AST can stay around for a long time, it is worth making an
effort to shrink it down when we have a chance.
This commit is contained in:
Andreas Kling 2022-11-26 20:45:06 +01:00 committed by Linus Groh
parent 2e98c17347
commit 9721da2e6a
2 changed files with 18 additions and 0 deletions

View file

@ -280,6 +280,14 @@ public:
m_children.append(move(child));
}
void shrink_to_fit()
{
m_children.shrink_to_fit();
m_lexical_declarations.shrink_to_fit();
m_var_declarations.shrink_to_fit();
m_functions_hoistable_with_annexB_extension.shrink_to_fit();
}
NonnullRefPtrVector<Statement> const& children() const { return m_children; }
virtual void dump(int indent) const override;
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const override;