浏览代码

don't use int switch for empty cases

Nicolas Cannasse 16 年之前
父节点
当前提交
04e78540dc
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      gencpp.ml

+ 3 - 0
gencpp.ml

@@ -609,6 +609,9 @@ let list_num l = string_of_int (List.length l);;
 
 
 let only_int_cases cases =
+	match cases with
+	| [] -> false
+	| _ ->
 	not (List.exists (fun (cases,expression) -> 
 			List.exists (fun case -> match case.eexpr with TConst (TInt _) -> false | _ -> true ) cases
 				) cases );;