2
0
Эх сурвалжийг харах

Revert "[prefab] Pre allocate children array on clone"

This reverts commit e2b7da2e4a25b28adeb7551533e363b47498b936.
Clement Espeute 1 жил өмнө
parent
commit
a4937f6af4

+ 1 - 6
hrt/prefab/Macros.hx

@@ -762,12 +762,7 @@ class Macros {
 							else
 							else
 							{
 							{
 								var _a : Array<Dynamic> = cast $e{source};
 								var _a : Array<Dynamic> = cast $e{source};
-								var target = [];
-								target.resize(_a.length);
-								for (idx => _elem in _a) {
-									target[idx] = $e{hrt.prefab.Macros.deepCopyRec(params[0], macro @:pos(source.pos) _elem, targetType, null, custom, true)};
-								}
-								target;
+								[for (_elem in _a) $e{hrt.prefab.Macros.deepCopyRec(params[0], macro @:pos(source.pos) _elem, targetType, null, custom, true)}];
 							}
 							}
 						};
 						};
 					case "String":
 					case "String":

+ 2 - 5
hrt/prefab/Prefab.hx

@@ -195,15 +195,12 @@ class Prefab {
 		var inst = Type.createEmptyInstance(thisClass);
 		var inst = Type.createEmptyInstance(thisClass);
 		inst.postCloneInit();		// Macro function that init all the non serializable fields of a prefab
 		inst.postCloneInit();		// Macro function that init all the non serializable fields of a prefab
 		inst.children = [];
 		inst.children = [];
-		inst.children.resize(children.length);
 		inst.__newInit(parent, sh);// Macro function that contains the code of the new function
 		inst.__newInit(parent, sh);// Macro function that contains the code of the new function
 
 
 		inst.copy(this);
 		inst.copy(this);
 		if (withChildren) {
 		if (withChildren) {
-			for (idx => child in children) {
-				var cloneChild = child.clone(null, sh);
-				@:bypassAccessor cloneChild.parent = inst;
-				inst.children[idx] = cloneChild;
+			for (child in children) {
+				child.clone(inst, sh);
 			}
 			}
 		}
 		}