@@ -38,41 +38,35 @@ pub(crate) fn simplify_log_expr(log_expr: ArcDfPredNode, changed: &mut bool) ->
38
38
if let DfPredType :: Constant ( ConstantType :: Bool ) = new_child. typ {
39
39
let data = ConstantPred :: from_pred_node ( new_child) . unwrap ( ) . value ( ) ;
40
40
* changed = true ;
41
- // TrueExpr
42
- if data. as_bool ( ) {
43
- if op == LogOpType :: And {
44
- // skip True in And
45
- continue ;
46
- }
47
- if op == LogOpType :: Or {
41
+
42
+ match ( data. as_bool ( ) , op) {
43
+ ( true , LogOpType :: Or ) => {
48
44
// replace whole exprList with True
49
45
return ConstantPred :: bool ( true ) . into_pred_node ( ) ;
50
46
}
51
- unreachable ! ( "no other type in logOp" ) ;
52
- }
53
- // FalseExpr
54
- if op == LogOpType :: And {
55
- // replace whole exprList with False
56
- return ConstantPred :: bool ( false ) . into_pred_node ( ) ;
57
- }
58
- if op == LogOpType :: Or {
59
- // skip False in Or
60
- continue ;
47
+ ( false , LogOpType :: And ) => {
48
+ // replace whole exprList with False
49
+ return ConstantPred :: bool ( false ) . into_pred_node ( ) ;
50
+ }
51
+ _ => {
52
+ // skip True in `And`, and False in `Or`
53
+ continue ;
54
+ }
61
55
}
62
- unreachable ! ( "no other type in logOp" ) ;
63
56
} else if !new_children_set. contains ( & new_child) {
64
57
new_children_set. insert ( new_child. clone ( ) ) ;
65
58
new_children. push ( new_child) ;
66
59
}
67
60
}
68
61
if new_children. is_empty ( ) {
69
- if op == LogOpType :: And {
70
- return ConstantPred :: bool ( true ) . into_pred_node ( ) ;
71
- }
72
- if op == LogOpType :: Or {
73
- return ConstantPred :: bool ( false ) . into_pred_node ( ) ;
62
+ match op {
63
+ LogOpType :: And => {
64
+ return ConstantPred :: bool ( true ) . into_pred_node ( ) ;
65
+ }
66
+ LogOpType :: Or => {
67
+ return ConstantPred :: bool ( false ) . into_pred_node ( ) ;
68
+ }
74
69
}
75
- unreachable ! ( "no other type in logOp" ) ;
76
70
}
77
71
if new_children. len ( ) == 1 {
78
72
* changed = true ;
0 commit comments