There is no point in performing a lookup + store -- just perform
a conditional load, which saves a bucket lookup in the not-present
case.
Change-Id: Idacb1eba11da59fbb3c9554fa0d2f5fac92717d3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
54493897a40acdff60c5be6ae833e549bded9372)
}
private NodeHolder getNode(final NodeId id) {
- if (this.nodes.containsKey(id)) {
- LOG.debug("Node {} is already present", id);
- return this.nodes.get(id);
- }
-
- final NodeHolder ret = new NodeHolder(id);
- this.nodes.put(id, ret);
- return ret;
+ return this.nodes.computeIfAbsent(id, NodeHolder::new);
}
private void putNode(final WriteTransaction trans, final NodeHolder holder) {