commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (LANG-1367) ObjectUtils.identityToString(Object) and friends should allocate builders and buffers with a size
Date Fri, 10 Nov 2017 19:27:00 GMT

     [ 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)

Mime
View raw message