Improve CPU efficiency for high throughput systems by caching immutable hash result for the SimpleConfigObject.

This commit is contained in:
Daltro Gama 2018-04-25 17:27:04 -03:00
parent 6a20c6fc5a
commit 3682aeecdf

View File

@ -30,6 +30,7 @@ final class SimpleConfigObject extends AbstractConfigObject implements Serializa
final private Map<String, AbstractConfigValue> value;
final private boolean resolved;
final private boolean ignoresFallbacks;
private Integer mapHashValue = null;
SimpleConfigObject(ConfigOrigin origin,
Map<String, AbstractConfigValue> value, ResolveStatus status,
@ -596,7 +597,12 @@ final class SimpleConfigObject extends AbstractConfigObject implements Serializa
public int hashCode() {
// note that "origin" is deliberately NOT part of equality
// neither are other "extras" like ignoresFallbacks or resolve status.
return mapHash(this);
if (this.mapHashValue == null) {
return this.mapHashValue=mapHash(this);
}
else {
return mapHashValue;
}
}
@Override