From 8a2d3c3c9c0571e8676616cc709c50dae7810dfe Mon Sep 17 00:00:00 2001 From: Stiver Date: Wed, 4 Mar 2015 07:20:13 +0100 Subject: [PATCH] Performance improvement --- .../FastExtendedPostdominanceHelper.java | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/decompose/FastExtendedPostdominanceHelper.java b/src/org/jetbrains/java/decompiler/modules/decompiler/decompose/FastExtendedPostdominanceHelper.java index d7eeb56..d9f3eff 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/decompose/FastExtendedPostdominanceHelper.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/decompose/FastExtendedPostdominanceHelper.java @@ -89,8 +89,9 @@ public class FastExtendedPostdominanceHelper { stackPath.add(factory.spawnEmptySet()); Set setVisited = new HashSet(); - Set setStack = new HashSet(); + setVisited.add(stack.getFirst()); + while (!stack.isEmpty()) { Statement stat = stack.removeFirst(); @@ -104,34 +105,21 @@ public class FastExtendedPostdominanceHelper { continue; } - setVisited.add(stat); - - int domflag = 0; - - for (Iterator it = setPostdoms.iterator(); it.hasNext(); ) { - Integer post = it.next(); - - if (!path.contains(post)) { - if (domflag == 0) { - domflag = engine.isDominator(stat.id, head) ? 2 : 1; - } - - if (domflag == 1) { // not a dominator - it.remove(); - } - } + if(!engine.isDominator(stat.id, head)) { + setPostdoms.complement(path); + continue; } - + for (StatEdge edge : stat.getSuccessorEdges(StatEdge.TYPE_REGULAR)) { Statement edge_destination = edge.getDestination(); - if(!setVisited.contains(edge_destination) && !setStack.contains(edge_destination)) { + if(!setVisited.contains(edge_destination) /*&& !setStack.contains(edge_destination)*/) { stack.add(edge_destination); stackPath.add(path.getCopy()); - setStack.add(edge_destination); + setVisited.add(edge_destination); } } }