Browse Source

optimize `switch(e) { case true: true; default: false; }` to `e`

Simon Krajewski 11 years ago
parent
commit
d562cba9fc
1 changed files with 3 additions and 0 deletions
  1. 3 0
      optimizer.ml

+ 3 - 0
optimizer.ml

@@ -1035,6 +1035,9 @@ let rec reduce_loop ctx e =
 	| TCall ({ eexpr = TField (o,FClosure (c,cf)) } as f,el) ->
 	| TCall ({ eexpr = TField (o,FClosure (c,cf)) } as f,el) ->
 		let fmode = (match c with None -> FAnon cf | Some c -> FInstance (c,cf)) in
 		let fmode = (match c with None -> FAnon cf | Some c -> FInstance (c,cf)) in
 		{ e with eexpr = TCall ({ f with eexpr = TField (o,fmode) },el) }
 		{ e with eexpr = TCall ({ f with eexpr = TField (o,fmode) },el) }
+	| TSwitch (e1,[[{eexpr = TConst (TBool true)}],{eexpr = TConst (TBool true)}],Some ({eexpr = TConst (TBool false)})) ->
+		(* introduced by extractors in some cases *)
+		e1
 	| _ ->
 	| _ ->
 		reduce_expr ctx e)
 		reduce_expr ctx e)