Skip to content

Commit 3adc7c3

Browse files
stsypanovsbrannen
authored andcommitted
Hoist concatenation of two constant Strings out of loops
Closes spring-projectsgh-24388
1 parent 59bef22 commit 3adc7c3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,13 @@ protected void registerBeanDefinition(String beanName, Map<?, ?> map, String pre
422422
ConstructorArgumentValues cas = new ConstructorArgumentValues();
423423
MutablePropertyValues pvs = new MutablePropertyValues();
424424

425+
String prefixWithSep = prefix + SEPARATOR;
426+
int beginIndex = prefix.length() + SEPARATOR.length();
427+
425428
for (Map.Entry<?, ?> entry : map.entrySet()) {
426429
String key = StringUtils.trimWhitespace((String) entry.getKey());
427-
if (key.startsWith(prefix + SEPARATOR)) {
428-
String property = key.substring(prefix.length() + SEPARATOR.length());
430+
if (key.startsWith(prefixWithSep)) {
431+
String property = key.substring(beginIndex);
429432
if (CLASS_KEY.equals(property)) {
430433
className = StringUtils.trimWhitespace((String) entry.getValue());
431434
}

spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,10 @@ public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotatio
166166
if (attributes == null) {
167167
return null;
168168
}
169+
String annotatedElement = "class '" + getClassName() + "'";
169170
for (AnnotationAttributes raw : attributes) {
170171
for (Map.Entry<String, Object> entry : AnnotationReadingVisitorUtils.convertClassValues(
171-
"class '" + getClassName() + "'", this.classLoader, raw, classValuesAsString).entrySet()) {
172+
annotatedElement, this.classLoader, raw, classValuesAsString).entrySet()) {
172173
allAttributes.add(entry.getKey(), entry.getValue());
173174
}
174175
}

0 commit comments

Comments
 (0)