From 92e28326a4f5ba68485d86d6f7f29c397d46d883 Mon Sep 17 00:00:00 2001 From: Skylot Date: Sat, 13 Jul 2019 13:24:52 +0300 Subject: [PATCH] misc: don't add same edge insn several times --- .../dex/attributes/nodes/EdgeInsnAttr.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/EdgeInsnAttr.java b/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/EdgeInsnAttr.java index c0f4c3f34..41324d9f4 100644 --- a/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/EdgeInsnAttr.java +++ b/jadx-core/src/main/java/jadx/core/dex/attributes/nodes/EdgeInsnAttr.java @@ -1,5 +1,7 @@ package jadx.core.dex.attributes.nodes; +import java.util.Objects; + import jadx.core.dex.attributes.AType; import jadx.core.dex.attributes.AttrList; import jadx.core.dex.attributes.IAttribute; @@ -14,8 +16,12 @@ public class EdgeInsnAttr implements IAttribute { public static void addEdgeInsn(BlockNode start, BlockNode end, InsnNode insn) { EdgeInsnAttr edgeInsnAttr = new EdgeInsnAttr(start, end, insn); - start.addAttr(AType.EDGE_INSN, edgeInsnAttr); - end.addAttr(AType.EDGE_INSN, edgeInsnAttr); + if (!start.getAll(AType.EDGE_INSN).contains(edgeInsnAttr)) { + start.addAttr(AType.EDGE_INSN, edgeInsnAttr); + } + if (!end.getAll(AType.EDGE_INSN).contains(edgeInsnAttr)) { + end.addAttr(AType.EDGE_INSN, edgeInsnAttr); + } } public EdgeInsnAttr(BlockNode start, BlockNode end, InsnNode insn) { @@ -41,6 +47,25 @@ public class EdgeInsnAttr implements IAttribute { return insn; } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EdgeInsnAttr that = (EdgeInsnAttr) o; + return start.equals(that.start) + && end.equals(that.end) + && insn.isDeepEquals(that.insn); + } + + @Override + public int hashCode() { + return Objects.hash(start, end, insn); + } + @Override public String toString() { return "EDGE_INSN: " + start + "->" + end + ' ' + insn;