BUG-7464: Reduce instanceof checks to null checks 76/49876/6
authorRobert Varga <rovarga@cisco.com>
Fri, 30 Dec 2016 15:07:31 +0000 (16:07 +0100)
committerRobert Varga <rovarga@cisco.com>
Mon, 9 Jan 2017 14:17:12 +0000 (15:17 +0100)
These instanceof checks function as null checks only,
hence they are not needed.

Change-Id: Iaf4df7a2b0c8b0d8d2e9bd46a02523f0693c07c0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNode.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/INode.java
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/TrieMap.java

index 489a6ef109826ccc0ea3e4f11abae12d8cab1a9b..b4882da95b9345e538e847e1e5e7993e8d4fd14b 100644 (file)
@@ -117,7 +117,7 @@ final class CNode<K, V> extends CNodeBase<K, V> {
             if (elem instanceof INode) {
                 INode<K, V> in = (INode<K, V>) elem;
                 narr [i] = in.copyToGen(ngen, ct);
-            } else if (elem instanceof BasicNode) {
+            } else if (elem != null) {
                 narr [i] = elem;
             }
             i += 1;
index 56b606c1fec37da0f98ee21bed16a9f8e663a0a8..3aca658cd50337deb9a375fab457508d502640f6 100644 (file)
@@ -67,7 +67,7 @@ final class INode<K, V> extends INodeBase<K, V> {
                         m = /* READ */ READ();
                         continue;
                     }
-                } else if (prev instanceof MainNode) {
+                } else if (prev != null) {
                     // Assume that you've read the root from the generation
                     // G.
                     // Assume that the snapshot algorithm is correct.
@@ -413,7 +413,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");
index 311f76349105481626fdbe92c8acd906276301f3..3b45b7ed1d3b62e8ee0b738ef7a77b18e2b5d347 100644 (file)
@@ -668,7 +668,7 @@ public class TrieMap<K, V> extends AbstractMap<K, V> implements ConcurrentMap<K,
                 }
 
                 lastReturned = r;
-                if(r instanceof Map.Entry) {
+                if (r != null) {
                     final Map.Entry<K, V> rr = r;
                     return nextEntry(rr);
                 }