From ee1b1035d21cf687bf676022a6cc4a55307bcd29 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sat, 11 Jun 2016 23:09:45 +0300 Subject: [PATCH] Fix strange bug --- .../teavm/optimization/LoopInversionImpl.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/teavm/optimization/LoopInversionImpl.java b/core/src/main/java/org/teavm/optimization/LoopInversionImpl.java index 571682b38..93140d33a 100644 --- a/core/src/main/java/org/teavm/optimization/LoopInversionImpl.java +++ b/core/src/main/java/org/teavm/optimization/LoopInversionImpl.java @@ -151,10 +151,14 @@ class LoopInversionImpl { } private LoopWithExits getLoopWithExits(Map cache, Loop loop) { - return cache.computeIfAbsent(loop, key -> - new LoopWithExits(key.getHead(), key.getParent() != null - ? getLoopWithExits(cache, key.getParent()) - : null)); + LoopWithExits result = cache.get(loop); + if (result == null) { + result = new LoopWithExits(loop.getHead(), loop.getParent() != null + ? getLoopWithExits(cache, loop.getParent()) + : null); + cache.put(loop, result); + } + return result; } private void sortLoops(LoopWithExits loop, Set visited, List target) { @@ -302,9 +306,7 @@ class LoopInversionImpl { private IntSet nodesToCopy() { IntSet result = new IntOpenHashSet(); - int[] nodes = this.nodes.toArray(); - Arrays.sort(nodes); - for (int node : nodes) { + for (int node : nodes.toArray()) { if (node == head || (node != bodyStart && !dom.dominates(bodyStart, node))) { result.add(node); }