# HG changeset patch # User Gilles Duboscq # Date 1378280391 -7200 # Node ID dbf968195ca12c7a40346e50df862230175fbf9a # Parent f521a1db1378fe58c5af1f5ddc8d61b211b26a9f use iterable for LoopFragment.toHirBlocks rather than reify collections diff -r f521a1db1378 -r dbf968195ca1 graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java --- a/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Tue Sep 03 18:19:30 2013 +0200 +++ b/graal/com.oracle.graal.loop/src/com/oracle/graal/loop/LoopFragment.java Wed Sep 04 09:39:51 2013 +0200 @@ -145,11 +145,11 @@ } } - protected static NodeBitMap computeNodes(Graph graph, Collection blocks) { + protected static NodeBitMap computeNodes(Graph graph, Iterable blocks) { return computeNodes(graph, blocks, Collections. emptyList()); } - protected static NodeBitMap computeNodes(Graph graph, Collection blocks, Collection earlyExits) { + protected static NodeBitMap computeNodes(Graph graph, Iterable blocks, Iterable earlyExits) { final NodeBitMap nodes = graph.createNodeBitMap(true); for (AbstractBeginNode b : blocks) { for (Node n : b.getBlockNodes()) { @@ -229,12 +229,28 @@ return false; } - public static Collection toHirBlocks(Collection blocks) { - List hir = new ArrayList<>(blocks.size()); - for (Block b : blocks) { - hir.add(b.getBeginNode()); - } - return hir; + public static NodeIterable toHirBlocks(final Iterable blocks) { + return new AbstractNodeIterable() { + + public Iterator iterator() { + final Iterator it = blocks.iterator(); + return new Iterator() { + + public void remove() { + throw new UnsupportedOperationException(); + } + + public AbstractBeginNode next() { + return it.next().getBeginNode(); + } + + public boolean hasNext() { + return it.hasNext(); + } + }; + } + + }; } /**