Commit 92e28326 authored by Skylot's avatar Skylot

misc: don't add same edge insn several times

parent 2dbdd1f0
package jadx.core.dex.attributes.nodes; package jadx.core.dex.attributes.nodes;
import java.util.Objects;
import jadx.core.dex.attributes.AType; import jadx.core.dex.attributes.AType;
import jadx.core.dex.attributes.AttrList; import jadx.core.dex.attributes.AttrList;
import jadx.core.dex.attributes.IAttribute; import jadx.core.dex.attributes.IAttribute;
...@@ -14,8 +16,12 @@ public class EdgeInsnAttr implements IAttribute { ...@@ -14,8 +16,12 @@ public class EdgeInsnAttr implements IAttribute {
public static void addEdgeInsn(BlockNode start, BlockNode end, InsnNode insn) { public static void addEdgeInsn(BlockNode start, BlockNode end, InsnNode insn) {
EdgeInsnAttr edgeInsnAttr = new EdgeInsnAttr(start, end, insn); EdgeInsnAttr edgeInsnAttr = new EdgeInsnAttr(start, end, insn);
start.addAttr(AType.EDGE_INSN, edgeInsnAttr); if (!start.getAll(AType.EDGE_INSN).contains(edgeInsnAttr)) {
end.addAttr(AType.EDGE_INSN, 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) { public EdgeInsnAttr(BlockNode start, BlockNode end, InsnNode insn) {
...@@ -42,6 +48,25 @@ public class EdgeInsnAttr implements IAttribute { ...@@ -42,6 +48,25 @@ public class EdgeInsnAttr implements IAttribute {
} }
@Override @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() { public String toString() {
return "EDGE_INSN: " + start + "->" + end + ' ' + insn; return "EDGE_INSN: " + start + "->" + end + ' ' + insn;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment