From: Robert Varga Date: Mon, 26 Jan 2015 13:40:23 +0000 (+0100) Subject: Speedup ModuleShardStrategy a bit X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=7085afacb0da42beab67dde5fc78e55e1bc98ed5 Speedup ModuleShardStrategy a bit Using isEmpty() is a bit faster, as it allows us to side-step a subsequent comparison. Change-Id: If2470ac293f0678e7bf158fccc00f263ed73a207 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java index fc7ebd94dd..e9ecf7eac3 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategy.java @@ -8,11 +8,10 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy; +import java.util.List; import org.opendaylight.controller.cluster.datastore.Configuration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import java.util.List; - public class ModuleShardStrategy implements ShardStrategy { public static final String NAME = "module"; @@ -26,10 +25,11 @@ public class ModuleShardStrategy implements ShardStrategy { this.configuration = configuration; } - @Override public String findShard(YangInstanceIdentifier path) { + @Override + public String findShard(YangInstanceIdentifier path) { List shardNames = configuration.getShardNamesFromModuleName(moduleName); - if(shardNames.size() == 0){ + if (shardNames.isEmpty()) { return DefaultShardStrategy.DEFAULT_SHARD; } return shardNames.get(0);