My question is simple. Some time ago StringBuilder was removed. What may be the reason of that? How can I deal with large strings now?
If you are using two or three string concatenations, use a string. StringBuilder will improve performance in cases where you make repeated modifications to a string or concatenate many strings together. In short, use StringBuilder only for a large number of concatenations.
Because StringBuilder is not a synchronized one whereas StringBuffer is a synchronized one. When using StringBuilder in a multithreaded environment multiple threads can acess the StringBuilder object simultaneously and the output it produces can't be predicted hence StringBuilder is not a thread safe...
StringBuilder is used to represent a mutable string of characters. Mutable means the string which can be changed. So String objects are immutable but StringBuilder is the mutable string type. It will not create a new modified instance of the current string object but do the modifications in the existing string object.
StringBuilder is used when we want to modify Java strings in-place. StringBuffer is a thread-safe equivalent similar of StringBuilder . StringBuilder has methods such as append , insert , or replace that allow to modify strings.
flash.utils.StringBuilder
was first introduced as a response to a lack of performance in String
concatanation. But then String
concatanation was optimized so there were no reason to use/keep this Class
.
Quote from http://onflex.org/ACDS/AS3TuningInsideAVM2JIT.pdf page 38
For awhile, we had a class flash.utils.StringBuilder for fast string concatenation What happened? A: We made the + operator super-fast by implementing compound strings (cords), so StringBuilder was unneeded and removed
I don't know for StringBuilder, for if you are using Flex there's the (open source) StringUtil Class. I guess you could use the it as is by copying the source file in your project. I know downloading the whole SDK for one file can be a turn off, but I don't think I can link directly to the file.
You can also check out this related question : StringBuilder in Flex
StringBuilder class was present in early Flash Player 8.5/9 Alphas and Betas, so I don't think they even finished it.
If you are worried about Visible text, you can use TextField.appendText method, which supposed to be optimised String modification method.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html#appendText()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With