perf(minifier): avoid creation of empty block when folding try finally (#26971)

This commit is contained in:
Armano authored and GitHub committed 2026-09-23 14:31:28 +00:00
1 parent e9ff529e87
commit 3471f2944c
1 file changed
+2 -4
@@ -413,10 +413,8 @@ impl<'a> PeepholeOptimizations {
if s.block.body.is_empty()
&& s.handler.as_ref().is_none_or(|handler| handler.body.body.is_empty())
{
let new_stmt = if let Some(finalizer) = &mut s.finalizer {
let mut block = BlockStatement::boxed(finalizer.span, [], ctx);
std::mem::swap(finalizer, &mut block);
Statement::BlockStatement(block)
let new_stmt = if let Some(finalizer) = s.finalizer.take() {
Statement::BlockStatement(finalizer)
} else {
Statement::new_empty_statement(s.span, ctx)
};