perf(minifier): short-circuit IfStatement termination on alternate (#25198)

Check alternate before consequent in `IfStatement::is_terminated()` so
the common if-without-else case short-circuits immediately through
`Option::is_some_and(...)`.
consequent is always present, while alternate is often absent, and
`try_minimize_if` already rotates `if (...) {} else { ... }` shapes to
help keep that common case favorable.

This is a micro-optimization.

Co-authored-by: Cameron <cameron.clark@hey.com>
This commit is contained in:
ArmanoandCameron authored and GitHub committed 2026-09-29 14:16:13 +00:00
1 parent da1fed245b
commit 3ca3ded17e
1 file changed
+1 -1
+1 -1
View File
@@ -21,7 +21,7 @@ impl IsTerminated for Statement<'_> {
impl IsTerminated for IfStatement<'_> {
fn is_terminated(&self) -> bool {
self.consequent.is_terminated() && self.alternate.is_terminated()
self.alternate.is_terminated() && self.consequent.is_terminated()
}
}