Speed up root overwrite check
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTree.java
index 786041f6e48e9c110faa1a8ce2a0f68882a7c5ec..b3688a87fa2baf0c71f46d47292cd8818525fc80 100644 (file)
@@ -475,26 +475,22 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
         }
     }
 
-    private void checkRootOverwrite(DataTreeCandidate candidate) {
+    private void checkRootOverwrite(final DataTreeCandidate candidate) {
         final DatastoreContext datastoreContext = shard.getDatastoreContext();
         if (!datastoreContext.isSnapshotOnRootOverwrite()) {
             return;
         }
 
         if (!datastoreContext.isPersistent()) {
-            return;
-        }
-
-        if (candidate.getRootNode().getModificationType().equals(ModificationType.UNMODIFIED)) {
+            // FIXME: why don't we want a snapshot in non-persistent state?
             return;
         }
 
         // top level container ie "/"
-        if ((candidate.getRootPath().equals(YangInstanceIdentifier.empty())
-                && candidate.getRootNode().getModificationType().equals(ModificationType.WRITE))) {
+        if (candidate.getRootPath().isEmpty()
+                && candidate.getRootNode().getModificationType() == ModificationType.WRITE) {
             LOG.debug("{}: shard root overwritten, enqueuing snapshot", logContext);
             shard.self().tell(new InitiateCaptureSnapshot(), noSender());
-            return;
         }
     }