Romain Guy wrote: > You can also avoid calling > toString() on it or passing it to methods that treat it as a String. > Calling toString() creates a copy of the buffer, which you certainly > don't want.
Yeah, I'm pretty bad about that one. I keep forgetting StringBuffer/StringBuilder implement CharSequence and that lots of things take a CharSequence directly instead of a String. For example, you can hand a StringBuffer/StringBuilder to TextView#setText(). Also, allocate a big enough StringBuffer/StringBuilder at the outset, so it does not have to expand its internal buffer. Its initial capacity appears to be 16 characters, if I am reading the Android/Harmony source correctly. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Need help for your Android OSS project? http://wiki.andmob.org/hado --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

