Prechádzať zdrojové kódy

fixes for amortized arrays

Nicolas Cannasse 18 rokov pred
rodič
commit
9ebe96de96
3 zmenil súbory, kde vykonal 19 pridanie a 7 odobranie
  1. 1 1
      std/Reflect.hx
  2. 1 1
      std/Type.hx
  3. 17 5
      std/neko/NekoArray__.hx

+ 1 - 1
std/Reflect.hx

@@ -123,7 +123,7 @@ class Reflect {
 		#else js
 			func.apply(o,args)
 		#else neko
-			__dollar__call(func,o,args.__a)
+			__dollar__call(func,o,args.neko())
 		#else error
 		#end
 			;

+ 1 - 1
std/Type.hx

@@ -274,7 +274,7 @@ class Type {
 			cl["apply"](o,args);
 			return o;
 		#else neko
-			return untyped __dollar__call(__dollar__objget(cl,__dollar__hash("new".__s)),cl,args.__a);
+			return untyped __dollar__call(__dollar__objget(cl,__dollar__hash("new".__s)),cl,args.neko());
 		#else js
 			if( args.length >= 6 ) throw "Too many arguments";
 			return untyped __new__(cl,args[0],args[1],args[2],args[3],args[4],args[5]);

+ 17 - 5
std/neko/NekoArray__.hx

@@ -61,7 +61,7 @@ class NekoArray__<T> implements Array<T> {
 	}
 
 	public function copy() {
-		return untyped Array.new1(__dollar__acopy(this.__a),this.length);
+		return untyped Array.new1(__dollar__asub(this.__a,0,this.length),this.length);
 	}
 
 	public function iterator() {
@@ -94,10 +94,11 @@ class NekoArray__<T> implements Array<T> {
 
 	public function join(delim : String) {
 		var s = new StringBuf();
-		var it = iterator();
-		for( i in it ) {
-			s.add(i);
-			if( it.hasNext() )
+		var a = untyped this.__a;
+		var max = this.length - 1;
+		for( p in 0...this.length ) {
+			s.add(a[p]);
+			if( p != max )
 				s.add(delim);
 		}
 		return s.toString();
@@ -309,5 +310,16 @@ class NekoArray__<T> implements Array<T> {
 		}
 	}
 
+	private function __neko() {
+		untyped {
+			var a = this.__a;
+			var sz = __dollar__asize(a);
+			if( sz != this.length ) {
+				a = __dollar__asub(a,0,this.length);
+				this.__a = a;
+			}
+			return a;
+		}
+	}
 
 }