ClassUtils.getShortClassName(String) inefficient
------------------------------------------------

                 Key: LANG-322
                 URL: https://issues.apache.org/jira/browse/LANG-322
             Project: Commons Lang
          Issue Type: Improvement
    Affects Versions: 2.3
            Reporter: Johann


ClassUtils.getShortClassName(String) is inefficient because it clones the Class 
name's char array which is then cloned again in the String(char[], int, int) 
constructor. Most of this garbage can be avoided.

Proposed fix:

public static String getShortClassName(String className) {
 [Null and empty checks]
 int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
 int innerIdx = className.indexOf(INNER_CLASS_SEPARATOR_CHAR, lastDotIdx == -1 
? 0 : lastDotIdx + 1);
 String out = result.substring(++lastDotIdx);
 if (innerIdx != -1) {
  out = out.replace(INNER_CLASS_SEPARATOR_CHAR, PACKAGE_SEPARATOR_CHAR);
 }
 return out;
}

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to