Use char notation to represent a character to improve performance.

This commit is contained in:
reudismam
2018-02-26 19:40:40 -03:00
parent 7938dcd8c4
commit e1b954289a
14 changed files with 23 additions and 23 deletions

View File

@ -190,7 +190,7 @@ public class RuleSetFactory {
List<RuleSetReferenceId> references = RuleSetReferenceId.parse(referenceString);
if (references.isEmpty()) {
throw new RuleSetNotFoundException(
"No RuleSetReferenceId can be parsed from the string: <" + referenceString + ">");
"No RuleSetReferenceId can be parsed from the string: <" + referenceString + '>');
}
return createRuleSet(references.get(0));
}
@ -620,7 +620,7 @@ public class RuleSetFactory {
if (referencedRule instanceof RuleReference) {
RuleReference ruleReference = (RuleReference) referencedRule;
if (LOG.isLoggable(Level.WARNING)) {
LOG.warning("Use Rule name " + ruleReference.getRuleSetReference().getRuleSetFileName() + "/"
LOG.warning("Use Rule name " + ruleReference.getRuleSetReference().getRuleSetFileName() + '/'
+ ruleReference.getOriginalName() + " instead of the deprecated Rule name "
+ otherRuleSetReferenceId
+ ". PMD " + PMDVersion.getNextMajorRelease()
@ -650,9 +650,9 @@ public class RuleSetFactory {
if (warnDeprecated && ruleReference.isDeprecated()) {
if (LOG.isLoggable(Level.WARNING)) {
LOG.warning("Use Rule name " + ruleReference.getRuleSetReference().getRuleSetFileName() + "/"
LOG.warning("Use Rule name " + ruleReference.getRuleSetReference().getRuleSetFileName() + '/'
+ ruleReference.getOriginalName() + " instead of the deprecated Rule name "
+ ruleSetReferenceId.getRuleSetFileName() + "/" + ruleReference.getName()
+ ruleSetReferenceId.getRuleSetFileName() + '/' + ruleReference.getName()
+ ". PMD " + PMDVersion.getNextMajorRelease()
+ " will remove support for this deprecated Rule name usage.");
}

View File

@ -251,7 +251,7 @@ public class RuleSetReferenceId {
int index = name.indexOf('-');
if (index >= 0) {
// Standard short name
result = "rulesets/" + name.substring(0, index) + "/" + name.substring(index + 1) + ".xml";
result = "rulesets/" + name.substring(0, index) + '/' + name.substring(index + 1) + ".xml";
} else {
// A release RuleSet?
if (name.matches("[0-9]+.*")) {
@ -428,7 +428,7 @@ public class RuleSetReferenceId {
if (allRules) {
return ruleSetFileName;
} else {
return ruleSetFileName + "/" + ruleName;
return ruleSetFileName + '/' + ruleName;
}
} else {

View File

@ -177,7 +177,7 @@ public class RuleSetWriter {
LanguageVersion maximumLanguageVersion = ruleReference.getOverriddenMaximumLanguageVersion();
Boolean deprecated = ruleReference.isOverriddenDeprecated();
String name = ruleReference.getOverriddenName();
String ref = ruleReference.getRuleSetReference().getRuleSetFileName() + "/"
String ref = ruleReference.getRuleSetReference().getRuleSetFileName() + '/'
+ ruleReference.getRule().getName();
String message = ruleReference.getOverriddenMessage();
String externalInfoUrl = ruleReference.getOverriddenExternalInfoUrl();

View File

@ -37,7 +37,7 @@ public final class RulesetsFactoryUtils {
ruleSets = factory.createRuleSets(rulesets);
printRuleNamesInDebug(ruleSets);
if (ruleSets.ruleCount() == 0) {
String msg = "No rules found. Maybe you mispelled a rule name? (" + rulesets + ")";
String msg = "No rules found. Maybe you mispelled a rule name? (" + rulesets + ')';
LOG.log(Level.SEVERE, msg);
throw new IllegalArgumentException(msg);
}

View File

@ -85,9 +85,9 @@ public class PMDTaskImpl {
SourceLanguage version = task.getSourceLanguage();
if (version != null) {
LanguageVersion languageVersion = LanguageRegistry
.findLanguageVersionByTerseName(version.getName() + " " + version.getVersion());
.findLanguageVersionByTerseName(version.getName() + ' ' + version.getVersion());
if (languageVersion == null) {
throw new BuildException("The following language is not supported:" + version + ".");
throw new BuildException("The following language is not supported:" + version + '.');
}
configuration.setDefaultLanguageVersion(languageVersion);
}

View File

@ -167,7 +167,7 @@ public class PMDParameters {
configuration.setAnalysisCacheLocation(params.cacheLocation);
LanguageVersion languageVersion = LanguageRegistry
.findLanguageVersionByTerseName(params.getLanguage() + " " + params.getVersion());
.findLanguageVersionByTerseName(params.getLanguage() + ' ' + params.getVersion());
if (languageVersion != null) {
configuration.getLanguageVersionDiscoverer().setDefaultLanguageVersion(languageVersion);
}

View File

@ -636,7 +636,7 @@ public class GUI implements CPDListener {
int separatorPos = sourceId.lastIndexOf(File.separatorChar);
label = "..." + sourceId.substring(separatorPos);
} else {
label = "(" + sourceIDs.size() + " separate files)";
label = '(' + sourceIDs.size() + " separate files)";
}
match.setLabel(label);

View File

@ -46,7 +46,7 @@ public class SimpleRenderer implements Renderer {
String source = match.getSourceCodeSlice();
if (trimLeadingWhitespace) {
String[] lines = source.split("[" + PMD.EOL + "]");
String[] lines = source.split('[' + PMD.EOL + ']');
int trimDepth = StringUtil.maxCommonLeadingWhitespaceForAll(lines);
if (trimDepth > 0) {
lines = StringUtil.trimStartOn(lines, trimDepth);

View File

@ -81,7 +81,7 @@ public abstract class MemberNode<S extends MemberNode<S, T>, T extends Member>
@Override
public String toString() {
return name + " " + desc;
return name + ' ' + desc;
}
public String toStringLong() {

View File

@ -99,7 +99,7 @@ public abstract class BaseLanguageModule implements Language {
@Override
public String toString() {
return "LanguageModule:" + name + "(" + this.getClass().getSimpleName() + ")";
return "LanguageModule:" + name + '(' + this.getClass().getSimpleName() + ')';
}
@Override

View File

@ -75,6 +75,6 @@ public class Attribute {
@Override
public String toString() {
return name + ":" + getValue() + ":" + parent;
return name + ':' + getValue() + ':' + parent;
}
}

View File

@ -51,13 +51,13 @@ public class VariableAccess {
@Override
public String toString() {
if (isDefinition()) {
return "Definition(" + variableName + ")";
return "Definition(" + variableName + ')';
}
if (isReference()) {
return "Reference(" + variableName + ")";
return "Reference(" + variableName + ')';
}
if (isUndefinition()) {
return "Undefinition(" + variableName + ")";
return "Undefinition(" + variableName + ')';
}
throw new RuntimeException("Access type was never set");
}

View File

@ -101,6 +101,6 @@ public class ImportWrapper {
@Override
public String toString() {
return "Import[name=" + name + ",fullname=" + fullname + ",static*=" + isStaticDemand + "]";
return "Import[name=" + name + ",fullname=" + fullname + ",static*=" + isStaticDemand + ']';
}
}

View File

@ -100,9 +100,9 @@ import org.apache.commons.lang3.StringUtils;
@Override
public String toString() {
return "[PropertyDescriptor: name=" + name() + ","
+ " type=" + (isMultiValue() ? "List<" + type() + ">" : type()) + ","
+ " value=" + defaultValue() + "]";
return "[PropertyDescriptor: name=" + name() + ','
+ " type=" + (isMultiValue() ? "List<" + type() + '>' : type()) + ','
+ " value=" + defaultValue() + ']';
}