forked from phoedos/pmd
optimized toArray conversion
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4525 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -53,7 +53,7 @@ public class SimpleRenderer implements Renderer {
|
||||
if (perl5Util != null) { // trimming wanted?
|
||||
List list = new ArrayList();
|
||||
perl5Util.split(list, PMD.EOL, source, 0);
|
||||
String[] lines = (String[])list.toArray(new String[] {});
|
||||
String[] lines = (String[])list.toArray(new String[list.size()]);
|
||||
int trimDepth = StringUtil.maxCommonLeadingWhitespaceForAll(lines);
|
||||
if (trimDepth > 0) {
|
||||
lines = StringUtil.trimStartOn(lines, trimDepth);
|
||||
|
@ -51,7 +51,7 @@ public class AttributeAxisIterator implements Iterator {
|
||||
Method[] preFilter = contextNode.getClass().getMethods();
|
||||
List postFilter = new ArrayList();
|
||||
for (int i = 0; i < preFilter.length; i++) {
|
||||
if (isAttribute(preFilter[i])) {
|
||||
if (isAttributeAccessor(preFilter[i])) {
|
||||
postFilter.add(new MethodWrapper(preFilter[i]));
|
||||
}
|
||||
}
|
||||
@ -84,21 +84,23 @@ public class AttributeAxisIterator implements Iterator {
|
||||
if (position == methodWrappers.length) {
|
||||
return null;
|
||||
}
|
||||
MethodWrapper m = methodWrappers[position];
|
||||
position++;
|
||||
MethodWrapper m = methodWrappers[position++];
|
||||
return new Attribute(node, m.name, m.method);
|
||||
}
|
||||
|
||||
protected boolean isAttribute(Method method) {
|
||||
protected boolean isAttributeAccessor(Method method) {
|
||||
|
||||
String methodName = method.getName();
|
||||
|
||||
return (Integer.TYPE == method.getReturnType() || Boolean.TYPE == method.getReturnType() || String.class == method.getReturnType())
|
||||
&& (method.getParameterTypes().length == 0)
|
||||
&& (Void.TYPE != method.getReturnType())
|
||||
&& !method.getName().startsWith("jjt")
|
||||
&& !method.getName().equals("toString")
|
||||
&& !method.getName().equals("getScope")
|
||||
&& !method.getName().equals("getClass")
|
||||
&& !method.getName().equals("getTypeNameNode")
|
||||
&& !method.getName().equals("getImportedNameNode")
|
||||
&& !method.getName().equals("hashCode");
|
||||
&& !methodName.startsWith("jjt")
|
||||
&& !methodName.equals("toString")
|
||||
&& !methodName.equals("getScope")
|
||||
&& !methodName.equals("getClass")
|
||||
&& !methodName.equals("getTypeNameNode")
|
||||
&& !methodName.equals("getImportedNameNode")
|
||||
&& !methodName.equals("hashCode");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user