diff truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 22175:5d2a12c9aae1

Use forEachChild instead of children iterator in Node.adoptHelper
author Andreas Woess <andreas.woess@oracle.com>
date Fri, 18 Sep 2015 16:37:04 +0200
parents dc83cc1f94f2
children 0d36601f233e
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Tue Sep 22 11:22:26 2015 +0200
+++ b/truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java	Fri Sep 18 16:37:04 2015 +0200
@@ -205,12 +205,14 @@
     }
 
     private void adoptHelper() {
-        Iterable<Node> children = this.getChildren();
-        for (Node child : children) {
-            if (child != null && child.getParent() != this) {
-                this.adoptHelper(child);
+        NodeUtil.forEachChild(this, new NodeVisitor() {
+            public boolean visit(Node child) {
+                if (child != null && child.getParent() != Node.this) {
+                    Node.this.adoptHelper(child);
+                }
+                return true;
             }
-        }
+        });
     }
 
     private void adoptUnadoptedHelper(final Node newChild) {
@@ -223,12 +225,14 @@
     }
 
     private void adoptUnadoptedHelper() {
-        Iterable<Node> children = this.getChildren();
-        for (Node child : children) {
-            if (child != null && child.getParent() == null) {
-                this.adoptUnadoptedHelper(child);
+        NodeUtil.forEachChild(this, new NodeVisitor() {
+            public boolean visit(Node child) {
+                if (child != null && child.getParent() == null) {
+                    Node.this.adoptUnadoptedHelper(child);
+                }
+                return true;
             }
-        }
+        });
     }
 
     /**