From d6d5435598440b9142e175c32deca4d3dcb03bcb Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Mon, 26 Oct 2015 20:42:26 +0100 Subject: [PATCH 1/2] faster getUnreachableActionCount --- .../action/fastactionlist/FastActionList.java | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java index 8efef6c70..55a5a39b7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java @@ -446,6 +446,27 @@ public class FastActionList implements Collection { return count; } + public int getUnreachableActionCountOld(ActionItem jump, ActionItem jumpTarget) { + ActionItem item = firstItem; + if (item == null) { + return 0; + } + + updateReachableFlagsOld(jump, jumpTarget); + jump.reachable = 0; + + int count = 0; + do { + if (item.reachable == 0) { + count++; + } + + item = item.next; + } while (item != firstItem); + + return count; + } + private void clearReachableFlags() { ActionItem item = firstItem; if (item == null) { @@ -477,6 +498,69 @@ public class FastActionList implements Collection { clearReachableFlags(); + firstItem.reachable = 1; + ActionItem firstItem2 = firstItem; + boolean modified = true; + while (modified) { + modified = false; + ActionItem item = firstItem2; + do { + ActionItem next = item.next; + //ActionItem alternativeNext = null; + Action action = item.action; + if (item.reachable == 1) { + item.reachable = 2; + modified = true; + + if (item == firstItem2) { + firstItem2 = next; + } + + if (item == jump) { + if (jumpTarget.reachable == 0) { + jumpTarget.reachable = 1; + //alternativeNext = jumpTarget; + } + } else { + + if (!action.isExit() && !(action instanceof ActionJump)) { + if (next.reachable == 0) { + next.reachable = 1; + } + } + + if (action instanceof GraphSourceItemContainer) { + for (ActionItem lastActionItem : item.getContainerLastActions()) { + if (lastActionItem != null && lastActionItem.next != null && lastActionItem.next.reachable == 0) { + lastActionItem.next.reachable = 1; + //alternativeNext = lastActionItem.next; + } + } + } + + ActionItem target = item.getJumpTarget(); + if (target != null) { + if (target.reachable == 0) { + target.reachable = 1; + //alternativeNext = target; + } + } + } + } + + //item = alternativeNext == null || next.reachable == 1 ? next : alternativeNext; + item = next; + } while (item != firstItem); + } + } + + private void updateReachableFlagsOld(ActionItem jump, ActionItem jumpTarget) { + if (firstItem == null) { + return; + } + + clearReachableFlags(); + firstItem.reachable = 1; boolean modified = true; while (modified) { From 48bc72c8e8f88c5704f84e5f04b3afb2ac3e3c11 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Tue, 27 Oct 2015 20:30:19 +0100 Subject: [PATCH 2/2] old function removed --- .../action/fastactionlist/FastActionList.java | 71 ------------------- 1 file changed, 71 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java index 55a5a39b7..755b433be 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/fastactionlist/FastActionList.java @@ -446,27 +446,6 @@ public class FastActionList implements Collection { return count; } - public int getUnreachableActionCountOld(ActionItem jump, ActionItem jumpTarget) { - ActionItem item = firstItem; - if (item == null) { - return 0; - } - - updateReachableFlagsOld(jump, jumpTarget); - jump.reachable = 0; - - int count = 0; - do { - if (item.reachable == 0) { - count++; - } - - item = item.next; - } while (item != firstItem); - - return count; - } - private void clearReachableFlags() { ActionItem item = firstItem; if (item == null) { @@ -554,56 +533,6 @@ public class FastActionList implements Collection { } } - private void updateReachableFlagsOld(ActionItem jump, ActionItem jumpTarget) { - if (firstItem == null) { - return; - } - - clearReachableFlags(); - - firstItem.reachable = 1; - boolean modified = true; - while (modified) { - modified = false; - for (ActionItem item : this) { - Action action = item.action; - if (item.reachable == 1) { - item.reachable = 2; - modified = true; - - if (item == jump) { - if (jumpTarget.reachable == 0) { - jumpTarget.reachable = 1; - } - - continue; - } - - if (!action.isExit() && !(action instanceof ActionJump) && item.next != null) { - if (item.next.reachable == 0) { - item.next.reachable = 1; - } - } - - ActionItem target = item.getJumpTarget(); - if (target != null) { - if (target.reachable == 0) { - target.reachable = 1; - } - } - - if (action instanceof GraphSourceItemContainer) { - for (ActionItem lastActionItem : item.getContainerLastActions()) { - if (lastActionItem != null && lastActionItem.next != null && lastActionItem.next.reachable == 0) { - lastActionItem.next.reachable = 1; - } - } - } - } - } - } - } - public ActionList updateActions() { List resultList = new ArrayList<>(size); ActionItem item = firstItem;