mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:47:35 +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:
parent
2e98c17347
commit
9721da2e6a
2 changed files with 18 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue