Explorar o código

[cpp] Tightened memory allocation for Vector

Hugh Sanderson %!s(int64=12) %!d(string=hai) anos
pai
achega
cd59594349
Modificáronse 1 ficheiros con 3 adicións e 5 borrados
  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
 	}