This is an automated email from the ASF dual-hosted git repository. sunlan pushed a commit to branch GROOVY_3_0_X in repository https://gitbox.apache.org/repos/asf/groovy.git
commit c5132d7b7ac323f8dcef591196142c99047dba07 Author: Daniel Sun <sun...@apache.org> AuthorDate: Wed Jan 15 09:38:39 2020 +0800 Trivial refactoring: avoid unnecessary regex usage (cherry picked from commit 93bedc444b7b5281867c9c002c34228abae37e89) --- .../main/groovy/org/apache/groovy/docgenerator/DocGenerator.groovy | 5 +---- .../org/apache/groovy/docgenerator/template.allclasses-frame.html | 2 +- .../org/apache/groovy/docgenerator/template.index-all.html | 2 +- .../org/apache/groovy/docgenerator/template.overview-frame.html | 2 +- .../src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java | 6 +++--- .../org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java | 6 +++--- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/subprojects/groovy-docgenerator/src/main/groovy/org/apache/groovy/docgenerator/DocGenerator.groovy b/subprojects/groovy-docgenerator/src/main/groovy/org/apache/groovy/docgenerator/DocGenerator.groovy index b02f60c..13b800d 100644 --- a/subprojects/groovy-docgenerator/src/main/groovy/org/apache/groovy/docgenerator/DocGenerator.groovy +++ b/subprojects/groovy-docgenerator/src/main/groovy/org/apache/groovy/docgenerator/DocGenerator.groovy @@ -529,10 +529,7 @@ class DocGenerator { } private static String filePathOf(String packageName) { - def fileSep = File.separator - // need to escape separator on windows for regex's sake - if (fileSep == '\\') fileSep *= 2 - return packageName.replaceAll(/\./, fileSep) + return packageName.replace('.', File.separator) } static File sourceFileOf(String pathOrClassName) { diff --git a/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.allclasses-frame.html b/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.allclasses-frame.html index 6710dbb..ccea851 100644 --- a/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.allclasses-frame.html +++ b/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.allclasses-frame.html @@ -31,7 +31,7 @@ <h2 title="All Classes">All Classes</h2> <ul> <% docTypes.each { docType -> %> - <li><a href="${docType.fullyQualifiedClassName.replaceAll(/\./, '/')}.html" title="${docType.interface ? 'interface' : 'class'} in ${docType.packageName}" target="classFrame"> + <li><a href="${docType.fullyQualifiedClassName.replace('.', '/')}.html" title="${docType.interface ? 'interface' : 'class'} in ${docType.packageName}" target="classFrame"> <% if (docType.interface) { %> <i>${docType.simpleClassName}</i> <% } else { %> diff --git a/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.index-all.html b/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.index-all.html index 31c5c4b..f3af86c 100644 --- a/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.index-all.html +++ b/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.index-all.html @@ -56,7 +56,7 @@ <h2><b>${indexMapEntry.key}</b></h2> <dl> <% indexMapEntry.value.each { it -> %> - <% final String classUrl = it.docType.fullyQualifiedClassName.replaceAll('\\.','/') + '.html' %> + <% final String classUrl = it.docType.fullyQualifiedClassName.replace('.','/') + '.html' %> <% if (it.docMethod) { %> <% final String methodUrl = classUrl + '#' + it.docMethod.name + '(' + it.docMethod.parametersSignature + ')' %> <dt><a href="${methodUrl}"><b>${it.docMethod.name}(${it.docMethod.parametersSignature})</b></a> - Method in ${it.docType.interface ? 'interface' : 'class'} ${it.docType.packageName}.<a href="${classUrl}">${it.docType.simpleClassName}</a></dt> diff --git a/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.overview-frame.html b/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.overview-frame.html index 2504982..5095433 100644 --- a/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.overview-frame.html +++ b/subprojects/groovy-docgenerator/src/main/resources/org/apache/groovy/docgenerator/template.overview-frame.html @@ -37,7 +37,7 @@ <ul> <li><a href="primitive-types/package-frame.html" title="Primitive types" target="packageFrame">Primitive types</a></li> <% packages.grep().each { %> - <li><a href="${it.name.replaceAll('\\.', '/')}/package-frame.html" title="${it.name}" target="packageFrame">${it.name}</a></li> + <li><a href="${it.name.replace('.', '/')}/package-frame.html" title="${it.name}" target="packageFrame">${it.name}</a></li> <% } %> </ul> </div> diff --git a/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java b/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java index 8903fb6..5fac475 100644 --- a/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java +++ b/subprojects/groovy-groovydoc/src/main/java/org/apache/groovy/antlr/GroovydocVisitor.java @@ -92,13 +92,13 @@ public class GroovydocVisitor extends ClassCodeVisitorSupport { String name = iNode.getClassName(); imports.add(name); if (iNode.getAlias() != null && !iNode.getAlias().isEmpty()) { - aliases.put(iNode.getAlias(), name.replaceAll("\\.", "/")); + aliases.put(iNode.getAlias(), name.replace('.', '/')); } } String name = node.getNameWithoutPackage(); if (node instanceof InnerClassNode) { - name = name.replaceAll("\\$", "."); + name = name.replace('$', '.'); } currentClassDoc = new SimpleGroovyClassDoc(imports, aliases, name, links); if (node.isEnum()) { @@ -298,7 +298,7 @@ public class GroovydocVisitor extends ClassCodeVisitorSupport { } private String makeType(ClassNode node) { - return node.getName().replaceAll("\\.", "/").replaceAll("\\$", "."); + return node.getName().replace('.', '/').replace('$', '.'); } @Override diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java index 140e4d2..a9c3201 100644 --- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java +++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java @@ -487,7 +487,7 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc imp sb.append(">"); return sb.toString(); } - return type.replaceAll("<", "<").replaceAll(">", ">"); + return type.replace("<", "<").replace(">", ">"); } } Matcher matcher = REF_LABEL_REGEX.matcher(type); @@ -989,11 +989,11 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc imp } public static String encodeSpecialSymbols(String text) { - return Matcher.quoteReplacement(text.replaceAll("@", "&at;")); + return Matcher.quoteReplacement(text.replace("@", "&at;")); } public static String decodeSpecialSymbols(String text) { - return text.replaceAll("&at;", "@"); + return text.replace("&at;", "@"); } public void setNameWithTypeArgs(String nameWithTypeArgs) {