Optimize ConfigurationPropertyName
This commit changes the iteration order when checking for element equality. This is based on the educated guess that child elements will likely differ while parents will probably be the same. E.g. comparing "spring.banner.charset" with "spring.banner.location" will now first check "charset" against "location" and thus saves some cycles for elements that will be the same. See gh-15782
This commit is contained in:
committed by
Andy Wilkinson
parent
7ed92e9be4
commit
5b3e1aa21a
@@ -237,7 +237,7 @@ public final class ConfigurationPropertyName
|
||||
if (this.getNumberOfElements() >= name.getNumberOfElements()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < this.elements.getSize(); i++) {
|
||||
for (int i = this.elements.getSize() - 1; i >= 0; i--) {
|
||||
if (!elementEquals(this.elements, name.elements, i)) {
|
||||
return false;
|
||||
}
|
||||
@@ -309,7 +309,7 @@ public final class ConfigurationPropertyName
|
||||
&& other.elements.canShortcutWithSource(ElementType.UNIFORM)) {
|
||||
return toString().equals(other.toString());
|
||||
}
|
||||
for (int i = 0; i < this.elements.getSize(); i++) {
|
||||
for (int i = this.elements.getSize() - 1; i >= 0; i--) {
|
||||
if (!elementEquals(this.elements, other.elements, i)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user