mirror of
https://github.com/lightbend/config.git
synced 2025-01-28 21:20:07 +08:00
Add shortcut that identity-equal lists/objects are equals()
The intent here is to make it fast to compare something to itself. Though maybe Java does this automatically, not sure.
This commit is contained in:
parent
66d21576b1
commit
fdce50fb76
@ -233,7 +233,8 @@ final class ConfigDelayedMerge extends AbstractConfigValue implements Unmergeabl
|
||||
// note that "origin" is deliberately NOT part of equality
|
||||
if (other instanceof ConfigDelayedMerge) {
|
||||
return canEqual(other)
|
||||
&& this.stack.equals(((ConfigDelayedMerge) other).stack);
|
||||
&& (this.stack == ((ConfigDelayedMerge) other).stack || this.stack
|
||||
.equals(((ConfigDelayedMerge) other).stack));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -170,8 +170,8 @@ final class ConfigDelayedMergeObject extends AbstractConfigObject implements Unm
|
||||
// note that "origin" is deliberately NOT part of equality
|
||||
if (other instanceof ConfigDelayedMergeObject) {
|
||||
return canEqual(other)
|
||||
&& this.stack
|
||||
.equals(((ConfigDelayedMergeObject) other).stack);
|
||||
&& (this.stack == ((ConfigDelayedMergeObject) other).stack || this.stack
|
||||
.equals(((ConfigDelayedMergeObject) other).stack));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -154,7 +154,8 @@ final class SimpleConfigList extends AbstractConfigValue implements ConfigList,
|
||||
// note that "origin" is deliberately NOT part of equality
|
||||
if (other instanceof SimpleConfigList) {
|
||||
// optimization to avoid unwrapped() for two ConfigList
|
||||
return canEqual(other) && value.equals(((SimpleConfigList) other).value);
|
||||
return canEqual(other)
|
||||
&& (value == ((SimpleConfigList) other).value || value.equals(((SimpleConfigList) other).value));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -443,6 +443,9 @@ final class SimpleConfigObject extends AbstractConfigObject implements Serializa
|
||||
}
|
||||
|
||||
private static boolean mapEquals(Map<String, ConfigValue> a, Map<String, ConfigValue> b) {
|
||||
if (a == b)
|
||||
return true;
|
||||
|
||||
Set<String> aKeys = a.keySet();
|
||||
Set<String> bKeys = b.keySet();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user