StringBuilder in Flex

后端 未结 2 957
萌比男神i
萌比男神i 2021-01-04 02:39

I\'m looking for fast string concatenation class or so in Flex. Like StringBuilder in Java.

Thanks

相关标签:
2条回答
  • 2021-01-04 03:10
    var str1:String = "Vinoth";
    var str2:String = "Babu";
    var str3:String = "Chennai";
    var str4:String = concat(str1, " ", str2, " ", str3)
    

    trace(str4) would result you str4 == "Vinoth babu Chennai"

    String Concat Class

    public class StringBuffer
    {
        public var buffer:Array = new Array();
    
        public function add(str:String):void
        {
            for (var i:Number = 0; i < str.length; i++)
            {
                buffer.push(str.charCodeAt(i));
            }
        }
    
        public function toString():String
        {
            return String.fromCharCode.apply(this, buffer);
        }
    }
    

    Here you have a more indepth than the above class written.

    http://blogs.adobe.com/pfarland/2007/10/avoiding_string_concatenation.html

    0 讨论(0)
  • 2021-01-04 03:17

    You can create an array of strings and then use String.concat to combine them.

    However, I've never seen string manipulation come up as a bottleneck when profiling a Flex app. I have in .NET, but not Flex.

    0 讨论(0)
提交回复
热议问题