Selaa lähdekoodia

use list instead of Hashtbl for cl_descendants

Simon Krajewski 8 vuotta sitten
vanhempi
commit
927aa03101
3 muutettua tiedostoa jossa 5 lisäystä ja 5 poistoa
  1. 1 1
      src/optimization/dce.ml
  2. 1 1
      src/optimization/filters.ml
  3. 3 3
      src/typing/type.ml

+ 1 - 1
src/optimization/dce.ml

@@ -223,7 +223,7 @@ let rec mark_dependent_fields dce csup n stat =
 	in
 	let rec loop_inheritance c =
 		loop c;
-		Hashtbl.iter (fun _ d -> loop_inheritance d) c.cl_descendants;
+		List.iter (fun d -> loop_inheritance d) c.cl_descendants;
 	in
 	loop_inheritance csup
 

+ 1 - 1
src/optimization/filters.ml

@@ -394,7 +394,7 @@ let save_class_state ctx t = match t with
 			c.cl_statics <- mk_pmap c.cl_ordered_statics;
 			c.cl_constructor <- Option.map restore_field csr;
 			c.cl_overrides <- over;
-			Hashtbl.clear c.cl_descendants;
+			c.cl_descendants <- [];
 		)
 	| _ ->
 		()

+ 3 - 3
src/typing/type.ml

@@ -222,7 +222,7 @@ and tclass = {
 		These are classes which directly extend or directly implement this class.
 		Populated automatically in post-processing step (Filters.run)
 	*)
-	mutable cl_descendants : (path, tclass) Hashtbl.t;
+	mutable cl_descendants : tclass list;
 }
 
 and tenum_field = {
@@ -402,7 +402,7 @@ let mk_class m path pos name_pos =
 		cl_overrides = [];
 		cl_build = (fun() -> Built);
 		cl_restore = (fun() -> ());
-		cl_descendants = Hashtbl.create 10
+		cl_descendants = [];
 	}
 
 let module_extra file sign time kind policy =
@@ -496,7 +496,7 @@ let rec is_parent csup c =
 		| Some (c,_) -> is_parent csup c
 
 let add_descendant c descendant =
-	Hashtbl.replace c.cl_descendants descendant.cl_path descendant
+	c.cl_descendants <- descendant :: c.cl_descendants
 
 let map loop t =
 	match t with