BUG-5280: speed FrontendClientMetadataBuilder up 64/49264/6
authorRobert Varga <rovarga@cisco.com>
Mon, 12 Dec 2016 18:07:43 +0000 (19:07 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Sat, 17 Dec 2016 00:47:08 +0000 (00:47 +0000)
ensureHistory() boils down to a simple computeIfAbsent(),
so make it more concise by using a simple constructor lambda.

Change-Id: Ia093ced071ae5e0411633d3c4f501a4e94c5de43
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/FrontendClientMetadataBuilder.java

index 0dab830584b70fd6e1f388ae2d819619a6c401a7..15e4304a4693942532c54abfea818f8c4af90e56 100644 (file)
@@ -69,13 +69,6 @@ final class FrontendClientMetadataBuilder implements Builder<FrontendClientMetad
     }
 
     private FrontendHistoryMetadataBuilder ensureHistory(final LocalHistoryIdentifier historyId) {
-        final FrontendHistoryMetadataBuilder existing = currentHistories.get(historyId);
-        if (existing != null) {
-            return existing;
-        }
-
-        final FrontendHistoryMetadataBuilder ret = new FrontendHistoryMetadataBuilder(historyId);
-        currentHistories.put(historyId, ret);
-        return ret;
+        return currentHistories.computeIfAbsent(historyId, FrontendHistoryMetadataBuilder::new);
     }
 }