On Mon, Jan 26, 2015 at 7:03 AM, Benedikt Ritter <brit...@apache.org> wrote:
> Hello Adrian
>
> 2015-01-24 19:43 GMT+01:00 Adrian Crum <adrian.c...@sandglass-software.com>:
>
>> Slightly off-topic but somewhat related...
>>
>> I saw a recent commit where a "performance improvement" went something
>> like this:
>>
>> StringBuilder sb = new StringBuilder();
>> sb.append("foo");
>>
>> was replaced with
>>
>> StringBuilder sb = new StringBuilder("foo");
>>
>> The change reduced the code by one line, but there was no "performance
>> improvement" - because the StringBuilder constructor calls append().
>>
>
> All methods on StringBuffer are synchronized, so there a slight overhead of
> acquiring the lock. This is usually the argument for using StringBuilder
> over StringBuffer.
>

But, there was no StringBuffer referenced in the above code snippet,
right, so the sync vs. non-sync doesn't apply.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to