Explorar el Código

[typer] optimize stack checking on special js-Class check

closes #7781
closes #7967
Simon Krajewski hace 6 años
padre
commit
e87b9c139f
Se han modificado 1 ficheros con 8 adiciones y 7 borrados
  1. 8 7
      src/context/abstractCast.ml

+ 8 - 7
src/context/abstractCast.ml

@@ -169,22 +169,23 @@ let find_multitype_specialization com a pl p =
 			) a.a_params pl in
 			if com.platform = Globals.Js && a.a_path = (["haxe";"ds"],"Map") then begin match tl with
 				| t1 :: _ ->
-					let rec loop stack t =
-						if List.exists (fun t2 -> fast_eq t t2) stack then
+					let stack = ref [] in
+					let rec loop t =
+						if List.exists (fun t2 -> fast_eq t t2) !stack then
 							t
 						else begin
-							let stack = t :: stack in
+							stack := t :: !stack;
 							match follow t with
 							| TAbstract ({ a_path = [],"Class" },_) ->
 								error (Printf.sprintf "Cannot use %s as key type to Map because Class<T> is not comparable" (s_type (print_context()) t1)) p;
 							| TEnum(en,tl) ->
-								PMap.iter (fun _ ef -> ignore(loop stack ef.ef_type)) en.e_constrs;
-								Type.map (loop stack) t
+								PMap.iter (fun _ ef -> ignore(loop ef.ef_type)) en.e_constrs;
+								Type.map loop t
 							| t ->
-								Type.map (loop stack) t
+								Type.map loop t
 						end
 					in
-					ignore(loop [] t1)
+					ignore(loop t1)
 				| _ -> assert false
 			end;
 			tl