Apparently String concatination is really cheap in AVM2, so let's just

keep things simple.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4443 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-11-02 23:53:30 +00:00
parent e9f13b66cd
commit 9ef2673464
+8 -5
View File
@@ -13,8 +13,8 @@ public class StringBuilder
*/ */
public function append (... args) :StringBuilder public function append (... args) :StringBuilder
{ {
while (args.length > 0) { for each (var o :Object in args) {
_array.push(String(args.shift())); _buf += String(o);
} }
return this; return this;
} }
@@ -24,10 +24,13 @@ public class StringBuilder
*/ */
public function toString () :String public function toString () :String
{ {
return _array.join(""); // it's ok, Strings are immutable
return _buf;
} }
/** Our array in which we place all arguments. */ /** The string upon which we build. Internally in AVM2, Strings have
protected var _array :Array = []; * been designed with a prefix pointer so that concatination is
* really cheap. */
protected var _buf :String = "";
} }
} }