From 9a0a54bebb2b4756ac30ab8a957ddca5ffe53892 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 12 Jul 2015 18:14:26 +0200 Subject: [PATCH] hashCode and equals --- .../jpexs/decompiler/flash/abc/ClassPath.java | 12 ++--- .../decompiler/flash/abc/ScriptPack.java | 12 ++--- .../decompiler/flash/abc/avm2/AVM2Code.java | 14 +++--- .../abc/avm2/model/LocalRegAVM2Item.java | 2 +- .../decompiler/flash/abc/types/Multiname.java | 31 +++++++----- .../action/model/CallFunctionActionItem.java | 13 ++--- .../action/model/DirectValueActionItem.java | 12 ++--- .../action/model/GetMemberActionItem.java | 13 ++--- .../action/model/GetVariableActionItem.java | 7 +-- .../flash/action/swf4/RegisterNumber.java | 6 +-- .../commonshape/ExportRectangle.java | 10 ++-- .../flash/exporters/commonshape/Point.java | 6 +-- .../decompiler/flash/helpers/FontHelper.java | 10 ++-- .../flash/helpers/collections/MyEntry.java | 11 ++--- .../decompiler/flash/timeline/Frame.java | 5 +- .../decompiler/flash/timeline/TagScript.java | 3 +- .../jpexs/decompiler/flash/types/MATRIX.java | 24 ++++----- .../jpexs/decompiler/graph/DottedChain.java | 7 +-- .../com/jpexs/decompiler/graph/GraphPart.java | 11 ++++- .../com/jpexs/decompiler/graph/GraphPath.java | 49 ++++++++++++------- .../src/com/jpexs/decompiler/graph/Loop.java | 5 +- .../decompiler/graph/TypeFunctionItem.java | 4 +- .../com/jpexs/decompiler/graph/TypeItem.java | 6 +-- .../decompiler/graph/model/BinaryOpItem.java | 15 +++--- 24 files changed, 160 insertions(+), 128 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java index 46f541284..4afffd1ea 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java @@ -24,9 +24,9 @@ import java.util.Objects; */ public class ClassPath { - public String packageStr; + public final String packageStr; - public String className; + public final String className; public ClassPath(String packageStr, String className) { this.packageStr = packageStr; @@ -41,8 +41,8 @@ public class ClassPath { @Override public int hashCode() { int hash = 7; - hash = 37 * hash + Objects.hashCode(this.packageStr); - hash = 37 * hash + Objects.hashCode(this.className); + hash = 37 * hash + Objects.hashCode(packageStr); + hash = 37 * hash + Objects.hashCode(className); return hash; } @@ -55,9 +55,9 @@ public class ClassPath { return false; } final ClassPath other = (ClassPath) obj; - if (!Objects.equals(this.packageStr, other.packageStr)) { + if (!Objects.equals(packageStr, other.packageStr)) { return false; } - return Objects.equals(this.className, other.className); + return Objects.equals(className, other.className); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index e8b17caa4..e9e72c944 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -224,9 +224,9 @@ public class ScriptPack extends AS3ClassTreeItem { @Override public int hashCode() { int hash = 7; - hash = 79 * hash + Objects.hashCode(this.abc); - hash = 79 * hash + this.scriptIndex; - hash = 79 * hash + Objects.hashCode(this.path); + hash = 79 * hash + Objects.hashCode(abc); + hash = 79 * hash + scriptIndex; + hash = 79 * hash + Objects.hashCode(path); return hash; } @@ -239,13 +239,13 @@ public class ScriptPack extends AS3ClassTreeItem { return false; } final ScriptPack other = (ScriptPack) obj; - if (!Objects.equals(this.abc, other.abc)) { + if (!Objects.equals(abc, other.abc)) { return false; } - if (this.scriptIndex != other.scriptIndex) { + if (scriptIndex != other.scriptIndex) { return false; } - if (!Objects.equals(this.path, other.path)) { + if (!Objects.equals(path, other.path)) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index a129b0937..89cbee71a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -298,6 +298,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -1767,9 +1768,9 @@ public class AVM2Code implements Cloneable { private class Slot { - public GraphTargetItem scope; + public final GraphTargetItem scope; - public Multiname multiname; + public final Multiname multiname; public Slot(GraphTargetItem scope, Multiname multiname) { this.scope = scope; @@ -1779,8 +1780,9 @@ public class AVM2Code implements Cloneable { @Override public boolean equals(Object obj) { if (obj instanceof Slot) { - return (((Slot) obj).scope.getThroughRegister() == scope.getThroughRegister()) - && (((Slot) obj).multiname == multiname); + Slot slot = (Slot) obj; + return (slot.scope.getThroughRegister() == scope.getThroughRegister()) + && (slot.multiname == multiname); } return false; } @@ -1788,8 +1790,8 @@ public class AVM2Code implements Cloneable { @Override public int hashCode() { int hash = 7; - hash = 59 * hash + (this.scope != null ? this.scope.hashCode() : 0); - hash = 59 * hash + (this.multiname != null ? this.multiname.hashCode() : 0); + hash = 59 * hash + (scope != null ? Objects.hashCode(scope.getThroughRegister()) : 0); + hash = 59 * hash + Objects.hashCode(multiname); return hash; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java index 6b898f45f..40322a77a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java @@ -36,7 +36,7 @@ import java.util.Set; public class LocalRegAVM2Item extends AVM2Item { - public int regIndex; + public final int regIndex; public GraphTargetItem computedValue; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java index f1d7ccdba..1c8339864 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java @@ -53,17 +53,17 @@ public class Multiname { private static final String[] multinameKindNames = new String[]{"Qname", "QnameA", "Multiname", "MultinameA", "RTQname", "RTQnameA", "MultinameL", "RTQnameL", "RTQnameLA", "MultinameLA", "TypeName"}; - public int kind = -1; + public final int kind; - public int name_index = 0; + public int name_index; - public int namespace_index = 0; + public final int namespace_index; - public int namespace_set_index = 0; + public final int namespace_set_index; - public int qname_index = 0; //for TypeName + public final int qname_index; //for TypeName - public List params; //for TypeName + public final List params; //for TypeName @Internal public boolean deleted; @@ -79,6 +79,11 @@ public class Multiname { } public Multiname() { + kind = -1; + namespace_index = 0; + namespace_set_index = 0; + qname_index = 0; + params = null; } public Multiname(int kind, int name_index, int namespace_index, int namespace_set_index, int qname_index, List params) { @@ -335,12 +340,12 @@ public class Multiname { @Override public int hashCode() { int hash = 7; - hash = 53 * hash + this.kind; - hash = 53 * hash + this.name_index; - hash = 53 * hash + this.namespace_index; - hash = 53 * hash + this.namespace_set_index; - hash = 53 * hash + this.qname_index; - hash = 53 * hash + Objects.hashCode(this.params); + hash = 53 * hash + kind; + hash = 53 * hash + name_index; + hash = 53 * hash + namespace_index; + hash = 53 * hash + namespace_set_index; + hash = 53 * hash + qname_index; + hash = 53 * hash + Objects.hashCode(params); return hash; } @@ -368,7 +373,7 @@ public class Multiname { if (this.qname_index != other.qname_index) { return false; } - if (!Objects.equals(this.params, other.params)) { + if (!Objects.equals(params, other.params)) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/CallFunctionActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/CallFunctionActionItem.java index 3c8ba7c73..2c70d733c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/CallFunctionActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/CallFunctionActionItem.java @@ -27,13 +27,14 @@ import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; import java.util.List; +import java.util.Objects; import java.util.Set; public class CallFunctionActionItem extends ActionItem { - public GraphTargetItem functionName; + public final GraphTargetItem functionName; - public List arguments; + public final List arguments; public GraphTargetItem calculatedFunction; @@ -99,8 +100,8 @@ public class CallFunctionActionItem extends ActionItem { @Override public int hashCode() { int hash = 3; - hash = 37 * hash + (this.functionName != null ? this.functionName.hashCode() : 0); - hash = 37 * hash + (this.arguments != null ? this.arguments.hashCode() : 0); + hash = 37 * hash + Objects.hashCode(functionName); + hash = 37 * hash + Objects.hashCode(arguments); return hash; } @@ -113,10 +114,10 @@ public class CallFunctionActionItem extends ActionItem { return false; } final CallFunctionActionItem other = (CallFunctionActionItem) obj; - if (this.functionName != other.functionName && (this.functionName == null || !this.functionName.equals(other.functionName))) { + if (!Objects.equals(functionName, other.functionName)) { return false; } - if (this.arguments != other.arguments && (this.arguments == null || !this.arguments.equals(other.arguments))) { + if (!Objects.equals(this.arguments, other.arguments)) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index feeb5402c..851b21771 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -39,11 +39,11 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { public Object value; - public List constants; + public final List constants; public GraphTargetItem computedRegValue; - public int pos = -1; + public final int pos; public DirectValueActionItem(Object o) { this(null, 0, o, new ArrayList<>()); @@ -204,8 +204,8 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { @Override public int hashCode() { int hash = 7; - hash = 71 * hash + Objects.hashCode(this.value); - hash = 71 * hash + System.identityHashCode(this.constants); + hash = 71 * hash + Objects.hashCode(value); + hash = 71 * hash + Objects.hashCode(constants); hash = 71 * hash + pos; return hash; } @@ -219,10 +219,10 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue { return false; } final DirectValueActionItem other = (DirectValueActionItem) obj; - if (!Objects.equals(this.value, other.value)) { + if (!Objects.equals(value, other.value)) { return false; } - if (!Objects.equals(this.constants, other.constants)) { + if (!Objects.equals(constants, other.constants)) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java index 7b5225723..5891d8633 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java @@ -28,12 +28,13 @@ import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; import java.util.ArrayList; import java.util.List; +import java.util.Objects; public class GetMemberActionItem extends ActionItem { - public GraphTargetItem object; + public final GraphTargetItem object; - public GraphTargetItem memberName; + public final GraphTargetItem memberName; @Override public List getAllSubItems() { @@ -71,8 +72,8 @@ public class GetMemberActionItem extends ActionItem { @Override public int hashCode() { int hash = 5; - hash = 47 * hash + (this.object != null ? this.object.hashCode() : 0); - hash = 47 * hash + (this.memberName != null ? this.memberName.hashCode() : 0); + hash = 47 * hash + Objects.hashCode(object); + hash = 47 * hash + Objects.hashCode(memberName); return hash; } @@ -85,10 +86,10 @@ public class GetMemberActionItem extends ActionItem { return false; } final GetMemberActionItem other = (GetMemberActionItem) obj; - if (this.object != other.object && (this.object == null || !this.object.equals(other.object))) { + if (!Objects.equals(object, other.object)) { return false; } - if (this.memberName != other.memberName && (this.memberName == null || !this.memberName.equals(other.memberName))) { + if (!Objects.equals(memberName, other.memberName)) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java index 2afbcf9a6..878af466e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java @@ -29,11 +29,12 @@ import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Set; public class GetVariableActionItem extends ActionItem { - public GraphTargetItem name; + public final GraphTargetItem name; private GraphTargetItem computedValue; @@ -115,7 +116,7 @@ public class GetVariableActionItem extends ActionItem { @Override public int hashCode() { int hash = 3; - hash = 13 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 13 * hash + Objects.hashCode(name); return hash; } @@ -128,7 +129,7 @@ public class GetVariableActionItem extends ActionItem { return false; } final GetVariableActionItem other = (GetVariableActionItem) obj; - if (this.name != other.name && (this.name == null || !this.name.equals(other.name))) { + if (!Objects.equals(name, other.name)) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java index 999cbef8c..36787c2be 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/RegisterNumber.java @@ -21,14 +21,14 @@ import java.io.Serializable; public class RegisterNumber implements Serializable { - public int number; + public final int number; public String name = null; @Override public int hashCode() { int hash = 3; - hash = 47 * hash + this.number; + hash = 47 * hash + number; return hash; } @@ -41,7 +41,7 @@ public class RegisterNumber implements Serializable { return false; } final RegisterNumber other = (RegisterNumber) obj; - if (this.number != other.number) { + if (number != other.number) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java index 0d778e83e..806bbefc4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/ExportRectangle.java @@ -25,13 +25,13 @@ import java.awt.geom.Rectangle2D; */ public class ExportRectangle { - public double xMin; + public final double xMin; - public double yMin; + public final double yMin; - public double xMax; + public final double xMax; - public double yMax; + public final double yMax; public ExportRectangle(double xMin, double yMin, double xMax, double yMax) { this.xMin = xMin; @@ -77,6 +77,6 @@ public class ExportRectangle { ExportRectangle r = (ExportRectangle) obj; return (xMin == r.xMin) && (yMin == r.yMin) && (xMax == r.xMax) && (yMax == r.yMax); } - return super.equals(obj); + return false; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java index 8f32128d6..489014005 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/commonshape/Point.java @@ -22,9 +22,9 @@ package com.jpexs.decompiler.flash.exporters.commonshape; */ public class Point { - public double x; + public final double x; - public double y; + public final double y; public Point(double x, double y) { this.x = x; @@ -44,6 +44,6 @@ public class Point { Point pt = (Point) obj; return (x == pt.x) && (y == pt.y); } - return super.equals(obj); + return false; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java index 5fdb1d958..be3190d29 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/FontHelper.java @@ -217,9 +217,9 @@ public class FontHelper { public static class KerningPair { - public char char1; + public final char char1; - public char char2; + public final char char2; public int kerning; @@ -247,13 +247,13 @@ public class FontHelper { return false; } final KerningPair other = (KerningPair) obj; - if (this.char1 != other.char1) { + if (char1 != other.char1) { return false; } - if (this.char2 != other.char2) { + if (char2 != other.char2) { return false; } - if (this.kerning != other.kerning) { + if (kerning != other.kerning) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyEntry.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyEntry.java index 9fada2fe8..19a2519c2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyEntry.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/helpers/collections/MyEntry.java @@ -44,8 +44,8 @@ public class MyEntry implements Entry { @Override public int hashCode() { int hash = 7; - hash = 61 * hash + Objects.hashCode(this.key); - hash = 61 * hash + Objects.hashCode(this.value); + hash = 61 * hash + Objects.hashCode(key); + hash = 61 * hash + Objects.hashCode(value); return hash; } @@ -57,12 +57,11 @@ public class MyEntry implements Entry { if (getClass() != obj.getClass()) { return false; } - @SuppressWarnings("unchecked") - final MyEntry other = (MyEntry) obj; - if (!Objects.equals(this.key, other.key)) { + final MyEntry other = (MyEntry) obj; + if (!Objects.equals(key, other.key)) { return false; } - if (!Objects.equals(this.value, other.value)) { + if (!Objects.equals(value, other.value)) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Frame.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Frame.java index 3d4719500..a9ef3c9b1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Frame.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Frame.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.types.RGB; import com.jpexs.decompiler.flash.types.RGBA; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.TreeMap; /** @@ -41,7 +42,7 @@ public class Frame implements TreeItem, Exportable { public RGB backgroundColor = new RGBA(0, 0, 0, 0); - public Timeline timeline; + public final Timeline timeline; public List sounds = new ArrayList<>(); @@ -92,7 +93,7 @@ public class Frame implements TreeItem, Exportable { public boolean equals(Object obj) { if (obj instanceof Frame) { Frame frameObj = (Frame) obj; - return timeline.equals(frameObj.timeline) && frame == frameObj.frame; + return Objects.equals(timeline, frameObj.timeline) && frame == frameObj.frame; } return false; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/TagScript.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/TagScript.java index 3382bbdf5..678a9f132 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/TagScript.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/TagScript.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.Exportable; import com.jpexs.decompiler.flash.treeitems.TreeItem; import java.util.List; +import java.util.Objects; /** * @@ -66,7 +67,7 @@ public class TagScript implements TreeItem, Exportable { @Override public boolean equals(Object obj) { if (obj instanceof TagScript) { - return tag.equals(((TagScript) obj).getTag()); + return Objects.equals(tag, ((TagScript) obj).tag); } return false; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MATRIX.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MATRIX.java index 00d11b9e6..4872146bb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MATRIX.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/MATRIX.java @@ -175,12 +175,12 @@ public class MATRIX implements Serializable { @Override public int hashCode() { int hash = 7; - hash = 37 * hash + this.getScaleX(); - hash = 37 * hash + this.getScaleY(); - hash = 37 * hash + this.getRotateSkew0(); - hash = 37 * hash + this.getRotateSkew1(); - hash = 37 * hash + this.translateX; - hash = 37 * hash + this.translateY; + hash = 37 * hash + getScaleX(); + hash = 37 * hash + getScaleY(); + hash = 37 * hash + getRotateSkew0(); + hash = 37 * hash + getRotateSkew1(); + hash = 37 * hash + translateX; + hash = 37 * hash + translateY; return hash; } @@ -193,22 +193,22 @@ public class MATRIX implements Serializable { return false; } final MATRIX other = (MATRIX) obj; - if (this.getScaleX() != other.getScaleX()) { + if (getScaleX() != other.getScaleX()) { return false; } - if (this.getScaleY() != other.getScaleY()) { + if (getScaleY() != other.getScaleY()) { return false; } - if (this.getRotateSkew0() != other.getRotateSkew0()) { + if (getRotateSkew0() != other.getRotateSkew0()) { return false; } - if (this.getRotateSkew1() != other.getRotateSkew1()) { + if (getRotateSkew1() != other.getRotateSkew1()) { return false; } - if (this.translateX != other.translateX) { + if (translateX != other.translateX) { return false; } - if (this.translateY != other.translateY) { + if (translateY != other.translateY) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java index e99d32d12..9c8bcca86 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java @@ -27,13 +27,14 @@ import java.util.Objects; */ public class DottedChain { - public List parts = new ArrayList<>(); + public final List parts; public DottedChain(List parts) { this.parts = new ArrayList<>(parts); } public DottedChain(String... parts) { + this.parts = new ArrayList<>(); for (int i = 0; i < parts.length; i++) { this.parts.add(parts[i]); } @@ -81,7 +82,7 @@ public class DottedChain { @Override public int hashCode() { int hash = 3; - hash = 89 * hash + Objects.hashCode(this.parts); + hash = 89 * hash + Objects.hashCode(parts); return hash; } @@ -97,7 +98,7 @@ public class DottedChain { return false; } final DottedChain other = (DottedChain) obj; - if (!Objects.equals(this.parts, other.parts)) { + if (!Objects.equals(parts, other.parts)) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPart.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPart.java index 74165eb54..2998bf3c8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPart.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPart.java @@ -28,14 +28,21 @@ import java.util.List; public class GraphPart implements Serializable { public static final int TYPE_NONE = 0; + public static final int TYPE_LOOP_HEADER = 1; + public static final int TYPE_PRELOOP = 3; + public static final int TYPE_REENTRY = 2; public boolean traversed = false; + public int DFSP_pos = 0; + public GraphPart iloop_header; + public int type = TYPE_NONE; + public boolean irreducible = false; public int start = 0; @@ -315,10 +322,10 @@ public class GraphPart implements Serializable { return false; } final GraphPart other = (GraphPart) obj; - if (this.start != other.start) { + if (start != other.start) { return false; } - if (this.end != other.end) { + if (end != other.end) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPath.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPath.java index 8906aef49..5e0ba49d3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPath.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPath.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.graph; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @@ -30,7 +31,7 @@ public class GraphPath implements Serializable { private final List vals = new ArrayList<>(); - public String rootName = ""; + public final String rootName; public GraphPath(String rootName, List keys, List vals) { this.rootName = rootName; @@ -39,10 +40,15 @@ public class GraphPath implements Serializable { } public GraphPath(List keys, List vals) { + rootName = ""; this.keys.addAll(keys); this.vals.addAll(vals); } + public GraphPath() { + rootName = ""; + } + public boolean startsWith(GraphPath p) { if (p.length() > length()) { return false; @@ -52,10 +58,10 @@ public class GraphPath implements Serializable { List otherVals = new ArrayList<>(p.vals); for (int i = 0; i < p.length(); i++) { - if (keys.get(i) != otherKeys.get(i)) { + if (!Objects.equals(keys.get(i), otherKeys.get(i))) { return false; } - if (vals.get(i) != otherVals.get(i)) { + if (!Objects.equals(vals.get(i), otherVals.get(i))) { return false; } } @@ -82,9 +88,6 @@ public class GraphPath implements Serializable { this.rootName = rootName; } - public GraphPath() { - } - public int length() { return vals.size(); } @@ -100,9 +103,9 @@ public class GraphPath implements Serializable { @Override public int hashCode() { int hash = 5; - hash = 23 * hash + (this.keys != null ? this.keys.hashCode() : 0); - hash = 23 * hash + (this.vals != null ? this.vals.hashCode() : 0); - hash = 23 * hash + (this.rootName != null ? this.rootName.hashCode() : 0); + hash = 23 * hash + arrHashCode(keys); + hash = 23 * hash + arrHashCode(vals); + hash = 23 * hash + Objects.hashCode(rootName); return hash; } @@ -115,34 +118,44 @@ public class GraphPath implements Serializable { return false; } final GraphPath other = (GraphPath) obj; - if (this.rootName == null && other.rootName != null) { - return false; - } - if (this.rootName != null && other.rootName == null) { + if ((rootName == null) != (other.rootName == null)) { return false; } - if (this.rootName != null && other.rootName != null) { - if (!this.rootName.equals(other.rootName)) { - return false; - } + if (!Objects.equals(rootName, other.rootName)) { + return false; } if (!arrMatch(keys, other.keys)) { return false; } + if (!arrMatch(vals, other.vals)) { return false; } + return true; } + private static int arrHashCode(List arr) { + if (arr == null || arr.isEmpty()) { + return 0; + } + + int hash = 5; + for (Integer i : arr) { + hash = 23 * hash + Objects.hashCode(i); + } + + return hash; + } + private static boolean arrMatch(List arr, List arr2) { if (arr.size() != arr2.size()) { return false; } for (int i = 0; i < arr.size(); i++) { - if (arr.get(i) != arr2.get(i)) { + if (!Objects.equals(arr.get(i), arr2.get(i))) { return false; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Loop.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Loop.java index 7a0bd4299..7a984b1d6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Loop.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Loop.java @@ -36,7 +36,7 @@ public class Loop implements Serializable { public List breakCandidatesLevels = new ArrayList<>(); - public long id; + public final long id; public int leadsToMark; @@ -73,10 +73,9 @@ public class Loop implements Serializable { return false; } final Loop other = (Loop) obj; - if (this.id != other.id) { + if (id != other.id) { return false; } return true; } - } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeFunctionItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeFunctionItem.java index ea47eab73..db91616d5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeFunctionItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeFunctionItem.java @@ -45,7 +45,7 @@ public class TypeFunctionItem extends GraphTargetItem { @Override public int hashCode() { int hash = 7; - hash = 83 * hash + Objects.hashCode(this.fullTypeName); + hash = 83 * hash + Objects.hashCode(fullTypeName); return hash; } @@ -58,7 +58,7 @@ public class TypeFunctionItem extends GraphTargetItem { return false; } final TypeFunctionItem other = (TypeFunctionItem) obj; - if (!Objects.equals(this.fullTypeName, other.fullTypeName)) { + if (!Objects.equals(fullTypeName, other.fullTypeName)) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java index 77f4320ed..4f18a478f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java @@ -40,7 +40,7 @@ public class TypeItem extends GraphTargetItem { public static UnboundedTypeItem UNBOUNDED = new UnboundedTypeItem(); - public DottedChain fullTypeName; + public final DottedChain fullTypeName; public TypeItem(String s) { this(s == null ? new DottedChain() : new DottedChain(s.split("\\."))); @@ -58,7 +58,7 @@ public class TypeItem extends GraphTargetItem { @Override public int hashCode() { int hash = 7; - hash = 83 * hash + Objects.hashCode(this.fullTypeName); + hash = 83 * hash + Objects.hashCode(fullTypeName); return hash; } @@ -71,7 +71,7 @@ public class TypeItem extends GraphTargetItem { return false; } final TypeItem other = (TypeItem) obj; - if (!Objects.equals(this.fullTypeName, other.fullTypeName)) { + if (!Objects.equals(fullTypeName, other.fullTypeName)) { return false; } return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java index cc4f85a45..aa3da921a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Set; public abstract class BinaryOpItem extends GraphTargetItem implements BinaryOp { @@ -31,7 +32,7 @@ public abstract class BinaryOpItem extends GraphTargetItem implements BinaryOp { public GraphTargetItem rightSide; - protected String operator = ""; + protected final String operator; @Override public GraphPart getFirstPart() { @@ -107,9 +108,9 @@ public abstract class BinaryOpItem extends GraphTargetItem implements BinaryOp { @Override public int hashCode() { int hash = 7; - hash = 71 * hash + (this.leftSide != null ? this.leftSide.hashCode() : 0); - hash = 71 * hash + (this.rightSide != null ? this.rightSide.hashCode() : 0); - hash = 71 * hash + (this.operator != null ? this.operator.hashCode() : 0); + hash = 71 * hash + Objects.hashCode(leftSide); + hash = 71 * hash + Objects.hashCode(rightSide); + hash = 71 * hash + Objects.hashCode(operator); return hash; } @@ -138,13 +139,13 @@ public abstract class BinaryOpItem extends GraphTargetItem implements BinaryOp { return false; } final BinaryOpItem other = (BinaryOpItem) obj; - if (this.leftSide != other.leftSide && (this.leftSide == null || !this.leftSide.equals(other.leftSide))) { + if (!Objects.equals(leftSide, other.leftSide)) { return false; } - if (this.rightSide != other.rightSide && (this.rightSide == null || !this.rightSide.equals(other.rightSide))) { + if (!Objects.equals(rightSide, other.rightSide)) { return false; } - if ((this.operator == null) ? (other.operator != null) : !this.operator.equals(other.operator)) { + if (!Objects.equals(operator, other.operator)) { return false; } return true;