RFR: String.join(), StringJoiner additions (original) (raw)
Martin Buchholz martinrb at google.com
Thu Apr 18 21:02:43 UTC 2013
- Previous message: RFR: String.join(), StringJoiner additions
- Next message: RFR: String.join(), StringJoiner additions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Apr 18, 2013 at 10:34 AM, Jim Gish <jim.gish at oracle.com> wrote:
That was a nice idea, but you don't want to change the value when you do toString(). Otherwise, if you subsequently add a new element, you're hosed because you've already added on the suffix.
You can cheaply save the current length, append the suffix, call toString, and reset the length back to the old value to avoid the overhead of String "+".
- Previous message: RFR: String.join(), StringJoiner additions
- Next message: RFR: String.join(), StringJoiner additions
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]