Browse Source

minor possible optimization

Nicolas Cannasse 14 years ago
parent
commit
fa89da60fd
1 changed files with 5 additions and 3 deletions
  1. 5 3
      typer.ml

+ 5 - 3
typer.ml

@@ -1057,11 +1057,13 @@ and type_switch ctx e cases def need_val p =
 				let params = (match !params with
 					| None -> None
 					| Some l ->
-						Some (List.map (fun (p,t) ->
+						let has = ref false in
+						let l = List.map (fun (p,t) ->
 							match p with
 							| None -> None, t
-							| Some v -> Some (add_local ctx v t), t
-						) l)
+							| Some v -> has := true; Some (add_local ctx v t), t
+						) l in
+						if !has then Some l else None
 				) in
 				let e = type_case_code e in
 				locals();