mirror of
https://github.com/lightbend/config.git
synced 2025-03-22 23:30:27 +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 Map<String, AbstractConfigValue> value;
|
||||||
final private boolean resolved;
|
final private boolean resolved;
|
||||||
final private boolean ignoresFallbacks;
|
final private boolean ignoresFallbacks;
|
||||||
|
private Integer mapHashValue = null;
|
||||||
|
|
||||||
SimpleConfigObject(ConfigOrigin origin,
|
SimpleConfigObject(ConfigOrigin origin,
|
||||||
Map<String, AbstractConfigValue> value, ResolveStatus status,
|
Map<String, AbstractConfigValue> value, ResolveStatus status,
|
||||||
@ -596,7 +597,12 @@ final class SimpleConfigObject extends AbstractConfigObject implements Serializa
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
// note that "origin" is deliberately NOT part of equality
|
// note that "origin" is deliberately NOT part of equality
|
||||||
// neither are other "extras" like ignoresFallbacks or resolve status.
|
// 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
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user