Mercurial > hg > truffle
diff graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java @ 21650:45ed86c4d127
Truffle: change NodeUtil.findFirstNodeInstance to include root in potential matches
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Mon, 01 Jun 2015 13:32:28 +0200 |
parents | 286aef83a9a7 |
children | f4cd6b1c2efc |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Mon Jun 01 17:47:28 2015 -0700 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Mon Jun 01 13:32:28 2015 +0200 @@ -454,14 +454,13 @@ } public static <T> T findFirstNodeInstance(Node root, Class<T> clazz) { - for (Node childNode : findNodeChildren(root)) { - if (clazz.isInstance(childNode)) { - return clazz.cast(childNode); - } else { - T node = findFirstNodeInstance(childNode, clazz); - if (node != null) { - return node; - } + if (clazz.isInstance(root)) { + return clazz.cast(root); + } + for (Node child : root.getChildren()) { + T node = findFirstNodeInstance(child, clazz); + if (node != null) { + return node; } } return null;