commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Evaristo (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-1410) StringsUtil.isBlank check null first
Date Thu, 06 Sep 2018 13:05:00 GMT

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

Mime
View raw message