Преглед на файлове

[cpp] haxe.io.Bytes.alloc use exact size

Previously, Bytes.alloc's underlying array would use non-exact sizing designed
to prepare for array growth, allocating 1.5x the memory it needs. Use
cpp.NativeArray.setSize to allocate an exact size.

This reaches parity with other platforms that allocate exact-sized arrays.
James Gray преди 10 години
родител
ревизия
a47cf4dcdc
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  1. 1 1
      std/haxe/io/Bytes.hx

+ 1 - 1
std/haxe/io/Bytes.hx

@@ -463,7 +463,7 @@ class Bytes {
 		return new Bytes(length, BytesData.alloc(length));
 		#elseif cpp
 		var a = new BytesData();
-		if (length>0) a[length-1] = untyped 0;
+		if (length>0) cpp.NativeArray.setSize(a, length);
 		return new Bytes(length, a);
 		#elseif cs
 		return new Bytes(length, new cs.NativeArray(length));