mirror of
https://github.com/lightbend/config.git
synced 2025-03-14 11:20:25 +08:00
Improve CPU efficiency for high throughput systems by caching immutable hash result for the SimpleConfigObject.
This commit is contained in:
parent
6a20c6fc5a
commit
3682aeecdf
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user