Skip to content

Commit f86b44f

Browse files
committed
Reduce StringBuilder creation in TypeExtractor.visitDeclared()
Closes gh-11845
1 parent 11f700a commit f86b44f

File tree

1 file changed

+11
-5
lines changed
  • spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor

1 file changed

+11
-5
lines changed

spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,18 @@ public String visitDeclared(DeclaredType type, Void none) {
187187
return getQualifiedName(enclosingElement) + "$"
188188
+ type.asElement().getSimpleName().toString();
189189
}
190-
StringBuilder name = new StringBuilder();
191-
name.append(getQualifiedName(type.asElement()));
192-
if (!type.getTypeArguments().isEmpty()) {
193-
appendTypeArguments(type, name);
190+
String qualifiedName = getQualifiedName(type.asElement());
191+
if (type.getTypeArguments().isEmpty()) {
192+
return qualifiedName;
193+
}
194+
else {
195+
StringBuilder name = new StringBuilder();
196+
name.append(qualifiedName);
197+
if (!type.getTypeArguments().isEmpty()) {
198+
appendTypeArguments(type, name);
199+
}
200+
return name.toString();
194201
}
195-
return name.toString();
196202
}
197203

198204
private void appendTypeArguments(DeclaredType type, StringBuilder name) {

0 commit comments

Comments
 (0)