commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Speakmon (JIRA)" <j...@apache.org>
Subject [jira] Updated: (LANG-322) ClassUtils.getShortClassName(String) inefficient
Date Tue, 13 Nov 2007 01:27:50 GMT

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

Ben Speakmon updated LANG-322:
------------------------------

    Attachment: LANG-322.patch

Looks good here. Attaching patch.

> 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.


Mime
View raw message