You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2017/11/10 19:27:00 UTC
[jira] [Closed] (LANG-1367) ObjectUtils.identityToString(Object)
and friends should allocate builders and buffers with a size
[ https://issues.apache.org/jira/browse/LANG-1367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary Gregory closed LANG-1367.
------------------------------
Resolution: Fixed
Fix Version/s: 3.8
In git master.
> ObjectUtils.identityToString(Object) and friends should allocate builders and buffers with a size
> -------------------------------------------------------------------------------------------------
>
> Key: LANG-1367
> URL: https://issues.apache.org/jira/browse/LANG-1367
> Project: Commons Lang
> Issue Type: Improvement
> Components: lang.*
> Reporter: Gary Gregory
> Assignee: Gary Gregory
> Fix For: 3.8
>
>
> ObjectUtils.identityToString(Object) and friends should allocate builders and buffers with a size.
> Calling ObjectUtils.identityToString(Object) will allocate a {{StringBuilder}} and append to it. The {{StringBuilder}} will reallocate it's internal {{char[]}} at least once since most strings end up being larger than the default 16 characters initially allocated by a StringBuilder (on Oracle Java 7).
> This change computes the strings parts first and then allocates a {{StringBuilder}} of the right size.
> Similarly, the {{identityToString}} methods that accept an existing builder/buffer can call {{ensureCapacity}} to avoid any extraneous allocations.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)