Kaynağa Gözat

slightly improve field vs. overloads handling

Simon Krajewski 1 yıl önce
ebeveyn
işleme
9ffe8001d9
2 değiştirilmiş dosya ile 8 ekleme ve 13 silme
  1. 4 9
      src/compiler/hxb/hxbReader.ml
  2. 4 4
      src/compiler/hxb/hxbWriter.ml

+ 4 - 9
src/compiler/hxb/hxbReader.ml

@@ -1296,22 +1296,17 @@ class hxb_reader
 		cf.cf_flags <- flags;
 
 	method read_class_field_and_overloads_data (cf : tclass_field) =
-		let write cf =
-			let close = self#open_field_scope in
-			self#read_class_field_data cf;
-			close();
-		in
-		write cf;
 		let rec loop depth cfl = match cfl with
 			| cf :: cfl ->
 				assert (depth > 0);
-				write cf;
+				let close = self#open_field_scope in
+				self#read_class_field_data cf;
+				close();
 				loop (depth - 1) cfl
 			| [] ->
 				assert (depth = 0)
 		in
-		loop (read_uleb128 ch) cf.cf_overloads;
-
+		loop (read_uleb128 ch) (cf :: cf.cf_overloads);
 
 	method read_class_fields (c : tclass) =
 		begin match c.cl_kind with

+ 4 - 4
src/compiler/hxb/hxbWriter.ml

@@ -1750,13 +1750,13 @@ class hxb_writer
 		)
 
 	method write_class_field_and_overloads_data (cf : tclass_field) =
-		let write cf =
+		let cfl = cf :: cf.cf_overloads in
+		IOChunk.write_uleb128 chunk.io (List.length cfl);
+		List.iter (fun cf ->
 			let close = self#open_field_scope cf.cf_params in
 			self#write_class_field_data cf;
 			close();
-		in
-		write cf;
-		Chunk.write_list chunk cf.cf_overloads write
+		) cfl
 
 	(* Module types *)