[
https://issues.apache.org/jira/browse/LANG-322?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Henri Yandell closed LANG-322.
------------------------------
Resolution: Fixed
Attaching Ben's patch, generated from Johann's fix (r594394).
> 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
> Fix For: 2.4
>
> Attachments: LANG-322.patch
>
>
> 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.