[ 
https://issues.apache.org/jira/browse/LANG-604?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Henri Yandell updated LANG-604:
-------------------------------

    Fix Version/s: 3.1

Assigning to 3.1. It needs a little work to fix out, but the issue is largely 
defined. Not needed for 3.0 release.

> Optimize isBlank() for untrimmed strings
> ----------------------------------------
>
>                 Key: LANG-604
>                 URL: https://issues.apache.org/jira/browse/LANG-604
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>    Affects Versions: 3.0
>            Reporter: Kai Gülzau
>            Priority: Minor
>             Fix For: 3.1
>
>
> Change isBlank() to start iteration in the middle of the String.
> So you get better performance for untrimmed Strings like "   dummy   ".
> Here is my proposal:
> public static boolean isBlank(CharSequence cs) {
>   int strLen;
>   if (cs == null || (strLen = cs.length()) == 0) {
>     return true;
>   }
>   int mid = strLen / 2, i = mid;
>   for (; i < strLen; i++) {
>     if (!Character.isWhitespace(cs.charAt(i))) {
>       return false;
>     }
>   }
>   for (i = 0; i < mid; i++) {
>     if (!Character.isWhitespace(cs.charAt(i))) {
>       return false;
>     }
>   }
>   return true;
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to