Quellcode durchsuchen

[cpp] Tightened memory allocation for Vector

Hugh Sanderson vor 12 Jahren
Ursprung
Commit
cd59594349
1 geänderte Dateien mit 3 neuen und 5 gelöschten Zeilen
  1. 3 5
      std/haxe/ds/Vector.hx

+ 3 - 5
std/haxe/ds/Vector.hx

@@ -61,13 +61,11 @@ abstract Vector<T>(VectorData<T>) {
 			this = new cs.NativeArray(length);
 		#elseif java
 			this = new java.NativeArray(length);
+		#elseif cpp
+			this = untyped (new Array<T>()).__SetSizeExact(length);
 		#else
 			this = [];
-			#if cpp
-				untyped this.__SetSize(length);
-			#else
-				untyped this.length = length;
-			#end
+			untyped this.length = length;
 		#end
 	}