You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2022/06/20 18:13:38 UTC
[groovy] branch master updated: Trivial refactoring: `StringBuilder` can be replaced with `String`
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 3cf368f428 Trivial refactoring: `StringBuilder` can be replaced with `String`
3cf368f428 is described below
commit 3cf368f428bfe12e679bffdd14ee8056c15dad1f
Author: Daniel Sun <su...@apache.org>
AuthorDate: Tue Jun 21 02:13:00 2022 +0800
Trivial refactoring: `StringBuilder` can be replaced with `String`
---
.../java/org/codehaus/groovy/ast/MethodNode.java | 23 +++++++++++-----------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/ast/MethodNode.java b/src/main/java/org/codehaus/groovy/ast/MethodNode.java
index 331742c46d..79adea0704 100644
--- a/src/main/java/org/codehaus/groovy/ast/MethodNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/MethodNode.java
@@ -292,18 +292,17 @@ public class MethodNode extends AnnotatedNode {
public String getText() {
int mask = this instanceof ConstructorNode ? Modifier.constructorModifiers() : Modifier.methodModifiers();
String prettyName = getName().contains(" ") ? "\"" + getName() + "\"" : getName();
- return new StringBuilder(AstToTextHelper.getModifiersText(getModifiers() & mask))
- .append(' ')
- .append(toGenericTypesString(getGenericsTypes()))
- .append(AstToTextHelper.getClassText(getReturnType()))
- .append(' ')
- .append(prettyName)
- .append('(')
- .append(AstToTextHelper.getParametersText(getParameters()))
- .append(')')
- .append(AstToTextHelper.getThrowsClauseText(getExceptions()))
- .append(" { ... }")
- .toString();
+ return AstToTextHelper.getModifiersText(getModifiers() & mask) +
+ ' ' +
+ toGenericTypesString(getGenericsTypes()) +
+ AstToTextHelper.getClassText(getReturnType()) +
+ ' ' +
+ prettyName +
+ '(' +
+ AstToTextHelper.getParametersText(getParameters()) +
+ ')' +
+ AstToTextHelper.getThrowsClauseText(getExceptions()) +
+ " { ... }";
}
@Override