Răsfoiți Sursa

readded additional String/StringBuf indirection to avoid reference/value problems (fixed issue #1044)

Simon Krajewski 13 ani în urmă
părinte
comite
f1338eabec
2 a modificat fișierele cu 8 adăugiri și 9 ștergeri
  1. 0 1
      doc/CHANGES.txt
  2. 8 8
      std/StringBuf.hx

+ 0 - 1
doc/CHANGES.txt

@@ -1,7 +1,6 @@
 2012-xx-xx: 2.10
 	as3 : many small fixes
 	as3 : support for metadata and resources
-	js/flash : compile StringBuf as String for better performance
 	all : allow function calls as field variable initialization if a constant expression is returned
 	all : many DCE fixes
 

+ 8 - 8
std/StringBuf.hx

@@ -27,34 +27,34 @@
 	A String buffer is an efficient way to build a big string by
 	appending small elements together.
 **/
-@:native("String")
-extern class StringBuf {
+class StringBuf {
 
+	var b:String = "";
+	
 	/**
 		Creates a new string buffer.
 	**/
-	public function new():Void {
-	}
+	public function new() {}
 
 	/**
 		Adds the representation of any value to the string buffer.
 	**/
 	public inline function add( x : Dynamic ) : Void {
-		untyped __this__ += x;
+		b += x;
 	}
 
 	/**
 		Adds a part of a string to the string buffer.
 	**/
 	public inline function addChar( c : Int ) : Void {
-		untyped __this__ += String.fromCharCode(c);
+		b += String.fromCharCode(c);
 	}
 
 	/**
 		Adds a character to the string buffer.
 	**/
 	public inline function addSub( s : String, pos : Int, ?len : Int) : Void {
-		untyped __this__ += s.substr(pos, len);
+		b += s.substr(pos, len);
 	}
 
 	/**
@@ -62,7 +62,7 @@ extern class StringBuf {
 		The buffer is not emptied by this operation.
 	**/
 	public inline function toString() : String {
-		return untyped __this__;
+		return b;
 	}
 
 }