Skip to content

Truly independent web browser

LibRegex: Trim the instructions of compiled programs

Andreas Klingcf107e970b21
diff --git a/Libraries/LibRegex/Rust/src/compiler.rs b/Libraries/LibRegex/Rust/src/compiler.rs
index cdd61f35b80..e1ccb57ef2b 100644
--- a/Libraries/LibRegex/Rust/src/compiler.rs
+++ b/Libraries/LibRegex/Rust/src/compiler.rs
@@ -47,6 +47,8 @@ pub fn compile(pattern: &Pattern) -> Result<Program, Error> {
index: ng.index,
})
.collect();
+ // NB: Nothing adds to a program once it is compiled, so it keeps no room to grow.
+ compiler.program.instructions.shrink_to_fit();
Ok(compiler.program)
}