Speedup ModuleShardStrategy a bit 89/14489/1
authorRobert Varga <rovarga@cisco.com>
Mon, 26 Jan 2015 13:40:23 +0000 (14:40 +0100)
committerRobert Varga <rovarga@cisco.com>
Mon, 26 Jan 2015 14:38:17 +0000 (15:38 +0100)
Using isEmpty() is a bit faster, as it allows us to side-step a
subsequent comparison.

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

index fc7ebd9..e9ecf7e 100644 (file)
@@ -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<String> shardNames =
             configuration.getShardNamesFromModuleName(moduleName);
-        if(shardNames.size() == 0){
+        if (shardNames.isEmpty()) {
             return DefaultShardStrategy.DEFAULT_SHARD;
         }
         return shardNames.get(0);