@@ -37,7 +37,6 @@ use crate::{
37
37
38
38
mod arguments;
39
39
mod bools;
40
- mod collapse_vars;
41
40
mod conditionals;
42
41
mod dead_code;
43
42
mod evaluate;
@@ -526,13 +525,6 @@ impl Optimizer<'_> {
526
525
stmts. visit_with ( & mut AssertValid ) ;
527
526
}
528
527
529
- self . break_assignments_in_seqs ( stmts) ;
530
-
531
- #[ cfg( debug_assertions) ]
532
- {
533
- stmts. visit_with ( & mut AssertValid ) ;
534
- }
535
-
536
528
// stmts.extend(self.append_stmts.drain(..).map(T::from));
537
529
538
530
drop_invalid_stmts ( stmts) ;
@@ -542,99 +534,6 @@ impl Optimizer<'_> {
542
534
self . append_stmts = append_stmts;
543
535
}
544
536
545
- /// `a = a + 1` => `a += 1`.
546
- fn compress_bin_assignment_to_left ( & mut self , e : & mut AssignExpr ) {
547
- if e. op != op ! ( "=" ) {
548
- return ;
549
- }
550
-
551
- // TODO: Handle pure properties.
552
- let lhs = match & e. left {
553
- AssignTarget :: Simple ( SimpleAssignTarget :: Ident ( i) ) => i,
554
- _ => return ,
555
- } ;
556
-
557
- // If left operand of a binary expression is not same as lhs, this method has
558
- // nothing to do.
559
- let ( op, right) = match & mut * e. right {
560
- Expr :: Bin ( BinExpr {
561
- left, op, right, ..
562
- } ) => match & * * left {
563
- Expr :: Ident ( r) if lhs. sym == r. sym && lhs. ctxt == r. ctxt => ( op, right) ,
564
- _ => return ,
565
- } ,
566
- _ => return ,
567
- } ;
568
-
569
- // Don't break code for old browsers.
570
- match op {
571
- BinaryOp :: LogicalOr => return ,
572
- BinaryOp :: LogicalAnd => return ,
573
- BinaryOp :: Exp => return ,
574
- BinaryOp :: NullishCoalescing => return ,
575
- _ => { }
576
- }
577
-
578
- let op = match op {
579
- BinaryOp :: In | BinaryOp :: InstanceOf => return ,
580
-
581
- BinaryOp :: EqEq | BinaryOp :: NotEq | BinaryOp :: EqEqEq | BinaryOp :: NotEqEq => {
582
- // TODO(kdy1): Check if this is optimizable.
583
- return ;
584
- }
585
-
586
- BinaryOp :: Lt | BinaryOp :: LtEq | BinaryOp :: Gt | BinaryOp :: GtEq => return ,
587
-
588
- BinaryOp :: LShift => op ! ( "<<=" ) ,
589
- BinaryOp :: RShift => {
590
- op ! ( ">>=" )
591
- }
592
- BinaryOp :: ZeroFillRShift => {
593
- op ! ( ">>>=" )
594
- }
595
- BinaryOp :: Add => {
596
- op ! ( "+=" )
597
- }
598
- BinaryOp :: Sub => {
599
- op ! ( "-=" )
600
- }
601
- BinaryOp :: Mul => {
602
- op ! ( "*=" )
603
- }
604
- BinaryOp :: Div => {
605
- op ! ( "/=" )
606
- }
607
- BinaryOp :: Mod => {
608
- op ! ( "%=" )
609
- }
610
- BinaryOp :: BitOr => {
611
- op ! ( "|=" )
612
- }
613
- BinaryOp :: BitXor => {
614
- op ! ( "^=" )
615
- }
616
- BinaryOp :: BitAnd => {
617
- op ! ( "&=" )
618
- }
619
- BinaryOp :: LogicalOr => {
620
- op ! ( "||=" )
621
- }
622
- BinaryOp :: LogicalAnd => {
623
- op ! ( "&&=" )
624
- }
625
- BinaryOp :: Exp => {
626
- op ! ( "**=" )
627
- }
628
- BinaryOp :: NullishCoalescing => {
629
- op ! ( "??=" )
630
- }
631
- } ;
632
-
633
- e. op = op;
634
- e. right = right. take ( ) ;
635
- // Now we can compress it to an assignment
636
- }
637
-
638
537
///
639
538
/// - `undefined` => `void 0`
640
539
fn compress_undefined ( & mut self , e : & mut Expr ) {
@@ -1578,15 +1477,8 @@ impl VisitMut for Optimizer<'_> {
1578
1477
..self . ctx . clone ( )
1579
1478
} ;
1580
1479
e. left . visit_mut_with ( & mut * self . with_ctx ( ctx) ) ;
1581
-
1582
- if is_left_access_to_arguments ( & e. left ) {
1583
- // self.ctx.can_inline_arguments = false;
1584
- }
1585
1480
}
1586
1481
e. right . visit_mut_with ( self ) ;
1587
-
1588
- self . compress_bin_assignment_to_left ( e) ;
1589
- self . compress_bin_assignment_to_right ( e) ;
1590
1482
}
1591
1483
1592
1484
#[ cfg_attr( feature = "debug" , tracing:: instrument( skip_all) ) ]
@@ -1937,19 +1829,6 @@ impl VisitMut for Optimizer<'_> {
1937
1829
debug_assert_valid ( e) ;
1938
1830
}
1939
1831
1940
- if let Expr :: Bin ( bin) = e {
1941
- let expr = self . optimize_lit_cmp ( bin) ;
1942
- if let Some ( expr) = expr {
1943
- report_change ! ( "Optimizing: Literal comparison" ) ;
1944
- self . changed = true ;
1945
- * e = expr;
1946
- }
1947
- }
1948
-
1949
- if e. is_seq ( ) {
1950
- debug_assert_valid ( e) ;
1951
- }
1952
-
1953
1832
self . compress_cond_expr_if_similar ( e) ;
1954
1833
1955
1834
if e. is_seq ( ) {
@@ -2194,8 +2073,6 @@ impl VisitMut for Optimizer<'_> {
2194
2073
} ;
2195
2074
2196
2075
s. body . visit_mut_with ( & mut * self . with_ctx ( ctx. clone ( ) ) ) ;
2197
-
2198
- self . with_ctx ( ctx. clone ( ) ) . optimize_init_of_for_stmt ( s) ;
2199
2076
}
2200
2077
2201
2078
#[ cfg_attr( feature = "debug" , tracing:: instrument( skip_all) ) ]
@@ -2275,8 +2152,6 @@ impl VisitMut for Optimizer<'_> {
2275
2152
2276
2153
n. alt . visit_mut_with ( & mut * self . with_ctx ( ctx. clone ( ) ) ) ;
2277
2154
2278
- self . merge_nested_if ( n) ;
2279
-
2280
2155
self . negate_if_stmt ( n) ;
2281
2156
}
2282
2157
@@ -2472,10 +2347,6 @@ impl VisitMut for Optimizer<'_> {
2472
2347
fn visit_mut_seq_expr ( & mut self , n : & mut SeqExpr ) {
2473
2348
n. visit_mut_children_with ( self ) ;
2474
2349
2475
- self . shift_void ( n) ;
2476
-
2477
- self . shift_assignment ( n) ;
2478
-
2479
2350
self . merge_sequences_in_seq_expr ( n) ;
2480
2351
}
2481
2352
@@ -2707,12 +2578,6 @@ impl VisitMut for Optimizer<'_> {
2707
2578
debug_assert_eq ! ( self . prepend_stmts. len( ) , prepend_len) ;
2708
2579
debug_assert_eq ! ( self . append_stmts. len( ) , append_len) ;
2709
2580
debug_assert_valid ( s) ;
2710
-
2711
- self . compress_if_stmt_as_expr ( s) ;
2712
-
2713
- debug_assert_eq ! ( self . prepend_stmts. len( ) , prepend_len) ;
2714
- debug_assert_eq ! ( self . append_stmts. len( ) , append_len) ;
2715
- debug_assert_valid ( s) ;
2716
2581
}
2717
2582
2718
2583
#[ cfg_attr( feature = "debug" , tracing:: instrument( skip_all) ) ]
0 commit comments