From 9ef26734644b940388b1a913725c65976a3d078e Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Thu, 2 Nov 2006 23:53:30 +0000 Subject: [PATCH] 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 --- src/as/com/threerings/util/StringBuilder.as | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/as/com/threerings/util/StringBuilder.as b/src/as/com/threerings/util/StringBuilder.as index 616c306ae..9ee3d0285 100644 --- a/src/as/com/threerings/util/StringBuilder.as +++ b/src/as/com/threerings/util/StringBuilder.as @@ -13,8 +13,8 @@ public class StringBuilder */ public function append (... args) :StringBuilder { - while (args.length > 0) { - _array.push(String(args.shift())); + for each (var o :Object in args) { + _buf += String(o); } return this; } @@ -24,10 +24,13 @@ public class StringBuilder */ public function toString () :String { - return _array.join(""); + // it's ok, Strings are immutable + return _buf; } - /** Our array in which we place all arguments. */ - protected var _array :Array = []; + /** The string upon which we build. Internally in AVM2, Strings have + * been designed with a prefix pointer so that concatination is + * really cheap. */ + protected var _buf :String = ""; } }