BUG-7464: Do not check twice for prev to be null
[yangtools.git] / third-party / triemap / src / main / java / org / opendaylight / yangtools / triemap / INode.java
index 6c12cd88749ce5689fb75a52f02fdf2a986f3b02..2a59f01afea4e73a3eda6f00738851f10ace1975 100644 (file)
@@ -25,12 +25,6 @@ final class INode<K, V> extends INodeBase<K, V> {
      */
     static final Object RESTART = new Object();
 
-    static <K,V> INode<K,V> newRootNode() {
-        Gen gen = new Gen ();
-        CNode<K, V> cn = new CNode<> (0, new BasicNode[] {}, gen);
-        return new INode<>(gen, cn);
-    }
-
     INode(final Gen gen, final MainNode<K, V> bn) {
         super(gen, bn);
     }
@@ -55,7 +49,7 @@ final class INode<K, V> extends INodeBase<K, V> {
                 return null;
             } else {
                 // complete the GCAS
-                MainNode<K, V> prev = /* READ */ m.READ_PREV();
+                final MainNode<K, V> prev = /* READ */ m.READ_PREV();
                 INode<K, V> ctr = ct.readRoot(true);
 
                 if (prev == null) {
@@ -73,7 +67,7 @@ final class INode<K, V> extends INodeBase<K, V> {
                         m = /* READ */ READ();
                         continue;
                     }
-                } else if (prev instanceof MainNode) {
+                } else {
                     // Assume that you've read the root from the generation
                     // G.
                     // Assume that the snapshot algorithm is correct.
@@ -102,7 +96,6 @@ final class INode<K, V> extends INodeBase<K, V> {
                     }
                 }
             }
-            throw new RuntimeException ("Should not happen");
         }
     }
 
@@ -419,7 +412,7 @@ final class INode<K, V> extends INodeBase<K, V> {
             } else if (m instanceof LNode) {
                 // 5) an l-node
                 Option<V> tmp = ((LNode<K, V>) m).get (k);
-                return (tmp instanceof Option) ? ((Option<V>) tmp) : null;
+                return (tmp != null) ? ((Option<V>) tmp) : null;
             }
 
             throw new RuntimeException ("Should not happen");