Mercurial > hg > truffle
changeset 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 | 0bcfe8c6088f |
children | cd7ee4a382e4 |
files | truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java |
diffstat | 1 files changed, 14 insertions(+), 10 deletions(-) [+] |
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; } - } + }); } /**