Hi Roel,

Would you like to submit a patch and contribute?

Paul.

On Jun 4, 2013, at 4:16 PM, Roel Spilker <r.spil...@gmail.com> wrote:

> Looking at the implementation, the code in toString suggest that it's 
> worthwhile to optimize for an empty suffix (although I doubt that this 
> optimization has any measurable effects). But the constructor always 
> concatenates the prefix and the suffix, which results in both a new string 
> instance and a StringBuilder. If an empty suffix is common (actually, having 
> a separate constructor and the current toString implementation both suggest 
> it is), I think that the initializing the emptyValue field in the constructor 
> should be written as:
> 
> this.emptyValue = this.suffix.isEmpty() ? this.prefix : this.prefix + 
> this.suffix;
> 
> Actually, since there is also a setEmptyValue, I think that the field should 
> be left null, and toString and length check for null, resulting in even less 
> objects allocated in that scenario.
> 
> Roel
> 
> 
> 
> On Mon, Jun 3, 2013 at 5:43 PM, <paul.san...@oracle.com> wrote:
> Changeset: a79e2683eae3
> Author:    psandoz
> Date:      2013-06-03 17:37 +0200
> URL:       http://hg.openjdk.java.net/jdk8/tl/jdk/rev/a79e2683eae3
> 
> 8014383: StringJoiner example in class description not in sync with streams 
> API
> Reviewed-by: alanb
> 
> ! src/share/classes/java/util/StringJoiner.java
> 
> 

Reply via email to