mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-14 22:29:17 +00:00
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:
1 parent
da1fed245b
commit
3ca3ded17e
1 file changed
+1
-1
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user