You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ramesh Dhungel (Jira)" <ji...@apache.org> on 2020/03/08 15:11:00 UTC

[jira] [Commented] (LANG-1523) Avoid unnecessary allocation in StringUtils.wrapIfMissing

    [ https://issues.apache.org/jira/browse/LANG-1523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17054429#comment-17054429 ] 

Ramesh Dhungel commented on LANG-1523:
--------------------------------------

It seems like the String Builder is being created after checking if the str or the wrapper is null. What we can do is check if the str is already wrapped, if so then just return the str. This would avoid the String Builder being created.

> Avoid unnecessary allocation in StringUtils.wrapIfMissing
> ---------------------------------------------------------
>
>                 Key: LANG-1523
>                 URL: https://issues.apache.org/jira/browse/LANG-1523
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>    Affects Versions: 3.9
>            Reporter: Edgar Asatryan
>            Priority: Major
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> The *StringUtils.wrapIfMissing* creates a new instance of *StringBuilder* regardless of whether the input is wrapped or not.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)