Bladeren bron

gives best fit memory tmp instead of first largest

ncannasse 10 jaren geleden
bovenliggende
commit
1ee38ce0ba
1 gewijzigde bestanden met toevoegingen van 7 en 4 verwijderingen
  1. 7 4
      hxd/impl/Tmp.hx

+ 7 - 4
hxd/impl/Tmp.hx

@@ -5,12 +5,15 @@ class Tmp {
 	static var bytes = new Array<haxe.io.Bytes>();
 	static var bytes = new Array<haxe.io.Bytes>();
 
 
 	public static function getBytes( size : Int ) {
 	public static function getBytes( size : Int ) {
+		var found = -1;
 		for( i in 0...bytes.length ) {
 		for( i in 0...bytes.length ) {
 			var b = bytes[i];
 			var b = bytes[i];
-			if( b.length >= size ) {
-				bytes.splice(i, 1);
-				return b;
-			}
+			if( b.length >= size ) found = i;
+		}
+		if( found >= 0 ) {
+			var b = bytes[found];
+			bytes.splice(found, 1);
+			return b;
 		}
 		}
 		var sz = 1024;
 		var sz = 1024;
 		while( sz < size )
 		while( sz < size )