You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Yandell (Resolved) (JIRA)" <ji...@apache.org> on 2011/10/10 04:24:31 UTC
[jira] [Resolved] (LANG-604) Optimize isBlank() for untrimmed
strings
[ https://issues.apache.org/jira/browse/LANG-604?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell resolved LANG-604.
--------------------------------
Resolution: Won't Fix
Fix Version/s: (was: 3.0.2)
Resolving as WONTFIX.
> 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
>
> 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.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira