From: Robert Varga Date: Mon, 30 Apr 2018 09:06:26 +0000 (+0200) Subject: Use YangInstanceIdentifier.isEmpty() X-Git-Tag: release/fluorine~109 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=39550906e07020e085844bfdf770854da9d37117 Use YangInstanceIdentifier.isEmpty() This is a faster way of checking if an InstanceIdentifier is empty than comparison to a constant. Change-Id: I095576cdf1ac522348f3befaa8b14e84feaddf1c Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java index aca4e41d80..4b8dc4521f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/TransactionProxy.java @@ -104,14 +104,10 @@ public class TransactionProxy extends AbstractDOMStoreTransaction>, ReadFailedException> read(final YangInstanceIdentifier path) { Preconditions.checkState(type != TransactionType.WRITE_ONLY, "Reads from write-only transactions are not allowed"); + Preconditions.checkNotNull(path, "path should not be null"); LOG.trace("Tx {} read {}", getIdentifier(), path); - - if (YangInstanceIdentifier.EMPTY.equals(path)) { - return readAllData(); - } else { - return singleShardRead(shardNameFromIdentifier(path), path); - } + return path.isEmpty() ? readAllData() : singleShardRead(shardNameFromIdentifier(path), path); } private CheckedFuture>, ReadFailedException> singleShardRead(