You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Evaristo (JIRA)" <ji...@apache.org> on 2018/09/06 13:05:00 UTC

[jira] [Commented] (LANG-1410) StringsUtil.isBlank check null first

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

Evaristo commented on LANG-1410:
--------------------------------

There is minor memory saving with Yifan Guo approach when cs is null, because Java primitives have a default value when assignment is not explicit to a given value

int strLen; // This is euqivalent to int strLen = 0;
 if (cs == null || (strLen = cs.length()) == 0) {
    return true;
 }

That means that when cs is null variable strLen is using some memory

 

This code saves memory when cs == null

 

if (cs == null) {

    return true;

}

int strLen = cs.length(); 
if ( strLen == 0) {
    return true;
}

 

 

> StringsUtil.isBlank check null first
> ------------------------------------
>
>                 Key: LANG-1410
>                 URL: https://issues.apache.org/jira/browse/LANG-1410
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>            Reporter: Yifan Guo
>            Priority: Minor
>
> StringsUtil.isBlank should check null for cs first instead of declaring int strLen first.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)