commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Wang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LANG-1058) StringUtils.uncapitalize performance improvement
Date Sun, 26 Oct 2014 17:41:33 GMT

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

Leo Wang commented on LANG-1058:
--------------------------------

Exactly. Moreover, the substring() introduce extra String object which leads to more memory
pressure.

{code}
    public static String uncapitalize(final String str) {
        int strLen;
        if (str == null || (strLen = str.length()) == 0) {
            return str;
        }

        final char firstChar = str.charAt(0);
        final char newChar = Character.toLowerCase(firstChar);
        if (firstChar == newChar) {
            // already uncapitalized
            return str;
        }

        char[] newChars = new char[strLen];
        newChars[0] = newChar;
        str.getChars(1,strLen, newChars, 1);
        return String.valueOf(newChars);
    }
{code}

> StringUtils.uncapitalize performance improvement
> ------------------------------------------------
>
>                 Key: LANG-1058
>                 URL: https://issues.apache.org/jira/browse/LANG-1058
>             Project: Commons Lang
>          Issue Type: Improvement
>          Components: lang.*
>            Reporter: Leo Wang
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message