summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>2014-06-25 17:23:07 +0200
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>2014-06-25 17:23:07 +0200
commit879330b55589d3b6b4ccf8f37673718002cdd017 (patch)
treec4d7631a7841cd0e1b4aaed8895a5a1560a2a16a /src
parente39ae1e71d497bcedccc1e88ccf01f274d377b76 (diff)
downloadfernflower-879330b55589d3b6b4ccf8f37673718002cdd017.tar
fernflower-879330b55589d3b6b4ccf8f37673718002cdd017.tar.gz
fernflower-879330b55589d3b6b4ccf8f37673718002cdd017.tar.lz
fernflower-879330b55589d3b6b4ccf8f37673718002cdd017.tar.xz
fernflower-879330b55589d3b6b4ccf8f37673718002cdd017.zip
minor optimization (o == this in equals)
Diffstat (limited to 'src')
-rw-r--r--src/de/fernflower/main/rels/NestedClassProcessor.java12
-rw-r--r--src/de/fernflower/modules/decompiler/exps/AnnotationExprent.java16
-rw-r--r--src/de/fernflower/modules/decompiler/exps/ArrayExprent.java14
-rw-r--r--src/de/fernflower/modules/decompiler/exps/AssignmentExprent.java18
-rw-r--r--src/de/fernflower/modules/decompiler/exps/ConstExprent.java15
-rw-r--r--src/de/fernflower/modules/decompiler/exps/ExitExprent.java13
-rw-r--r--src/de/fernflower/modules/decompiler/exps/FieldExprent.java22
-rw-r--r--src/de/fernflower/modules/decompiler/exps/FunctionExprent.java13
-rw-r--r--src/de/fernflower/modules/decompiler/exps/IfExprent.java14
-rw-r--r--src/de/fernflower/modules/decompiler/exps/InvocationExprent.java26
-rw-r--r--src/de/fernflower/modules/decompiler/exps/MonitorExprent.java15
-rw-r--r--src/de/fernflower/modules/decompiler/exps/NewExprent.java22
-rw-r--r--src/de/fernflower/modules/decompiler/exps/SwitchExprent.java14
-rw-r--r--src/de/fernflower/modules/decompiler/exps/VarExprent.java18
-rw-r--r--src/de/fernflower/modules/decompiler/sforms/FlattenStatementsHelper.java21
-rw-r--r--src/de/fernflower/modules/decompiler/vars/VarVersionEdge.java13
-rw-r--r--src/de/fernflower/modules/decompiler/vars/VarVersionPaar.java12
-rw-r--r--src/de/fernflower/struct/consts/LinkConstant.java29
-rw-r--r--src/de/fernflower/struct/consts/PrimitiveConstant.java15
-rw-r--r--src/de/fernflower/struct/gen/FieldDescriptor.java13
-rw-r--r--src/de/fernflower/struct/gen/MethodDescriptor.java28
-rw-r--r--src/de/fernflower/struct/gen/VarType.java14
-rw-r--r--src/de/fernflower/util/FastFixedSetFactory.java10
-rw-r--r--src/de/fernflower/util/FastSetFactory.java10
-rw-r--r--src/de/fernflower/util/FastSparseSetFactory.java10
25 files changed, 173 insertions, 234 deletions
diff --git a/src/de/fernflower/main/rels/NestedClassProcessor.java b/src/de/fernflower/main/rels/NestedClassProcessor.java
index 7fdd4f8..4b7a466 100644
--- a/src/de/fernflower/main/rels/NestedClassProcessor.java
+++ b/src/de/fernflower/main/rels/NestedClassProcessor.java
@@ -997,13 +997,11 @@ public class NestedClassProcessor {
}
@Override
- public boolean equals(Object arg0) {
-
- if(!(arg0 instanceof VarFieldPair)) {
- return false;
- }
-
- VarFieldPair pair = (VarFieldPair)arg0;
+ public boolean equals(Object o) {
+ if(o == this) return true;
+ if(o == null || !(o instanceof VarFieldPair)) return false;
+
+ VarFieldPair pair = (VarFieldPair)o;
return keyfield.equals(pair.keyfield) && varpaar.equals(pair.varpaar);
}
diff --git a/src/de/fernflower/modules/decompiler/exps/AnnotationExprent.java b/src/de/fernflower/modules/decompiler/exps/AnnotationExprent.java
index f2bcb24..f8bddf1 100644
--- a/src/de/fernflower/modules/decompiler/exps/AnnotationExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/AnnotationExprent.java
@@ -95,14 +95,14 @@ public class AnnotationExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o!=null && o instanceof AnnotationExprent) {
- AnnotationExprent ann = (AnnotationExprent)o;
- return classname.equals(ann.classname) &&
- InterpreterUtil.equalLists(parnames, ann.parnames) &&
- InterpreterUtil.equalLists(parvalues, ann.parvalues);
- }
- return false;
- }
+ if(o == this) return true;
+ if(o == null || !(o instanceof AnnotationExprent)) return false;
+
+ AnnotationExprent ann = (AnnotationExprent)o;
+ return classname.equals(ann.classname) &&
+ InterpreterUtil.equalLists(parnames, ann.parnames) &&
+ InterpreterUtil.equalLists(parvalues, ann.parvalues);
+ }
public String getClassname() {
return classname;
diff --git a/src/de/fernflower/modules/decompiler/exps/ArrayExprent.java b/src/de/fernflower/modules/decompiler/exps/ArrayExprent.java
index 14c5b4b..14ac378 100644
--- a/src/de/fernflower/modules/decompiler/exps/ArrayExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/ArrayExprent.java
@@ -96,13 +96,13 @@ public class ArrayExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o!=null && o instanceof ArrayExprent) {
- ArrayExprent arr = (ArrayExprent)o;
- return InterpreterUtil.equalObjects(array, arr.getArray()) &&
- InterpreterUtil.equalObjects(index, arr.getIndex());
- }
- return false;
- }
+ if(o == this) return true;
+ if(o == null || !(o instanceof ArrayExprent)) return false;
+
+ ArrayExprent arr = (ArrayExprent)o;
+ return InterpreterUtil.equalObjects(array, arr.getArray()) &&
+ InterpreterUtil.equalObjects(index, arr.getIndex());
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == array) {
diff --git a/src/de/fernflower/modules/decompiler/exps/AssignmentExprent.java b/src/de/fernflower/modules/decompiler/exps/AssignmentExprent.java
index 3ea857f..2aa359d 100644
--- a/src/de/fernflower/modules/decompiler/exps/AssignmentExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/AssignmentExprent.java
@@ -140,20 +140,20 @@ public class AssignmentExprent extends Exprent {
buffer.append(left.toJava(indent));
}
- buffer.append((condtype==CONDITION_NONE?" = ":funceq[condtype]) +res);
+ buffer.append(condtype == CONDITION_NONE ? " = " : funceq[condtype]).append(res);
return buffer.toString();
}
public boolean equals(Object o) {
- if(o!=null && o instanceof AssignmentExprent) {
- AssignmentExprent as = (AssignmentExprent)o;
- return InterpreterUtil.equalObjects(left, as.getLeft()) &&
- InterpreterUtil.equalObjects(right, as.getRight()) &&
- condtype == as.getCondtype();
- }
- return false;
- }
+ if(o == this) return true;
+ if(o == null || !(o instanceof AssignmentExprent)) return false;
+
+ AssignmentExprent as = (AssignmentExprent)o;
+ return InterpreterUtil.equalObjects(left, as.getLeft()) &&
+ InterpreterUtil.equalObjects(right, as.getRight()) &&
+ condtype == as.getCondtype();
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == left) {
diff --git a/src/de/fernflower/modules/decompiler/exps/ConstExprent.java b/src/de/fernflower/modules/decompiler/exps/ConstExprent.java
index 26d7355..43aad3e 100644
--- a/src/de/fernflower/modules/decompiler/exps/ConstExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/ConstExprent.java
@@ -276,14 +276,13 @@ public class ConstExprent extends Exprent {
public boolean equals(Object o) {
- if(o!=null && o instanceof ConstExprent) {
- ConstExprent cn = (ConstExprent)o;
-
- return InterpreterUtil.equalObjects(consttype, cn.getConsttype()) &&
- InterpreterUtil.equalObjects(value, cn.getValue());
- }
- return false;
- }
+ if(o == this) return true;
+ if(o == null || !(o instanceof ConstExprent)) return false;
+
+ ConstExprent cn = (ConstExprent)o;
+ return InterpreterUtil.equalObjects(consttype, cn.getConsttype()) &&
+ InterpreterUtil.equalObjects(value, cn.getValue());
+ }
public boolean hasBooleanValue() {
diff --git a/src/de/fernflower/modules/decompiler/exps/ExitExprent.java b/src/de/fernflower/modules/decompiler/exps/ExitExprent.java
index d062eef..763af3b 100644
--- a/src/de/fernflower/modules/decompiler/exps/ExitExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/ExitExprent.java
@@ -120,14 +120,13 @@ public class ExitExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o!=null && o instanceof ExitExprent) {
- ExitExprent et = (ExitExprent)o;
+ if(o == this) return true;
+ if(o == null || !(o instanceof ExitExprent)) return false;
- return exittype==et.getExittype() &&
- InterpreterUtil.equalObjects(value, et.getValue());
- }
- return false;
- }
+ ExitExprent et = (ExitExprent)o;
+ return exittype==et.getExittype() &&
+ InterpreterUtil.equalObjects(value, et.getValue());
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == value) {
diff --git a/src/de/fernflower/modules/decompiler/exps/FieldExprent.java b/src/de/fernflower/modules/decompiler/exps/FieldExprent.java
index 0e1400a..d4334a0 100644
--- a/src/de/fernflower/modules/decompiler/exps/FieldExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/FieldExprent.java
@@ -155,18 +155,16 @@ public class FieldExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o!=null && o instanceof FieldExprent) {
- FieldExprent ft = (FieldExprent)o;
-
- return InterpreterUtil.equalObjects(name, ft.getName()) &&
- InterpreterUtil.equalObjects(classname, ft.getClassname()) &&
- isStatic == ft.isStatic() &&
- InterpreterUtil.equalObjects(instance, ft.getInstance()) &&
- InterpreterUtil.equalObjects(descriptor, ft.getDescriptor());
-
- }
- return false;
- }
+ if(o == this) return true;
+ if(o == null || !(o instanceof FieldExprent)) return false;
+
+ FieldExprent ft = (FieldExprent)o;
+ return InterpreterUtil.equalObjects(name, ft.getName()) &&
+ InterpreterUtil.equalObjects(classname, ft.getClassname()) &&
+ isStatic == ft.isStatic() &&
+ InterpreterUtil.equalObjects(instance, ft.getInstance()) &&
+ InterpreterUtil.equalObjects(descriptor, ft.getDescriptor());
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == instance) {
diff --git a/src/de/fernflower/modules/decompiler/exps/FunctionExprent.java b/src/de/fernflower/modules/decompiler/exps/FunctionExprent.java
index 230fc5b..e0cebe4 100644
--- a/src/de/fernflower/modules/decompiler/exps/FunctionExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/FunctionExprent.java
@@ -429,14 +429,13 @@ public class FunctionExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o!=null && o instanceof FunctionExprent) {
- FunctionExprent fe = (FunctionExprent)o;
+ if(o == this) return true;
+ if(o == null || !(o instanceof FunctionExprent)) return false;
- return functype==fe.getFunctype() &&
- InterpreterUtil.equalLists(lstOperands, fe.getLstOperands()); // TODO: order of operands insignificant
- }
- return false;
- }
+ FunctionExprent fe = (FunctionExprent)o;
+ return functype==fe.getFunctype() &&
+ InterpreterUtil.equalLists(lstOperands, fe.getLstOperands()); // TODO: order of operands insignificant
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
for(int i=0;i<lstOperands.size();i++) {
diff --git a/src/de/fernflower/modules/decompiler/exps/IfExprent.java b/src/de/fernflower/modules/decompiler/exps/IfExprent.java
index a7990f0..0786f49 100644
--- a/src/de/fernflower/modules/decompiler/exps/IfExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/IfExprent.java
@@ -112,19 +112,17 @@ public class IfExprent extends Exprent {
StringBuffer buf = new StringBuffer("if(");
buf.append(condition.toJava(indent));
buf.append(")");
-
+
return buf.toString();
}
public boolean equals(Object o) {
- if(o!=null && o instanceof IfExprent) {
- IfExprent ie = (IfExprent)o;
+ if(o == this) return true;
+ if(o == null || !(o instanceof IfExprent)) return false;
- return InterpreterUtil.equalObjects(condition, ie.getCondition());
-
- }
- return false;
- }
+ IfExprent ie = (IfExprent)o;
+ return InterpreterUtil.equalObjects(condition, ie.getCondition());
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == condition) {
diff --git a/src/de/fernflower/modules/decompiler/exps/InvocationExprent.java b/src/de/fernflower/modules/decompiler/exps/InvocationExprent.java
index 7d312a5..1e4c596 100644
--- a/src/de/fernflower/modules/decompiler/exps/InvocationExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/InvocationExprent.java
@@ -393,20 +393,18 @@ public class InvocationExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o!=null && o instanceof InvocationExprent) {
- InvocationExprent it = (InvocationExprent)o;
-
- return InterpreterUtil.equalObjects(name, it.getName()) &&
- InterpreterUtil.equalObjects(classname, it.getClassname()) &&
- isStatic == it.isStatic() &&
- InterpreterUtil.equalObjects(instance, it.getInstance()) &&
- InterpreterUtil.equalObjects(descriptor, it.getDescriptor()) &&
- functype == it.getFunctype() &&
- InterpreterUtil.equalLists(lstParameters, it.getLstParameters());
-
- }
- return false;
- }
+ if(o == this) return true;
+ if(o == null || !(o instanceof InvocationExprent)) return false;
+
+ InvocationExprent it = (InvocationExprent)o;
+ return InterpreterUtil.equalObjects(name, it.getName()) &&
+ InterpreterUtil.equalObjects(classname, it.getClassname()) &&
+ isStatic == it.isStatic() &&
+ InterpreterUtil.equalObjects(instance, it.getInstance()) &&
+ InterpreterUtil.equalObjects(descriptor, it.getDescriptor()) &&
+ functype == it.getFunctype() &&
+ InterpreterUtil.equalLists(lstParameters, it.getLstParameters());
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == instance) {
diff --git a/src/de/fernflower/modules/decompiler/exps/MonitorExprent.java b/src/de/fernflower/modules/decompiler/exps/MonitorExprent.java
index dab8c72..21e8a8e 100644
--- a/src/de/fernflower/modules/decompiler/exps/MonitorExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/MonitorExprent.java
@@ -57,14 +57,13 @@ public class MonitorExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o!=null && o instanceof MonitorExprent) {
- MonitorExprent me = (MonitorExprent)o;
-
- return montype == me.getMontype() &&
- InterpreterUtil.equalObjects(value, me.getValue());
- }
- return false;
- }
+ if(o == this) return true;
+ if(o == null || !(o instanceof MonitorExprent)) return false;
+
+ MonitorExprent me = (MonitorExprent)o;
+ return montype == me.getMontype() &&
+ InterpreterUtil.equalObjects(value, me.getValue());
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == value) {
diff --git a/src/de/fernflower/modules/decompiler/exps/NewExprent.java b/src/de/fernflower/modules/decompiler/exps/NewExprent.java
index 8db9f89..eaa49ae 100644
--- a/src/de/fernflower/modules/decompiler/exps/NewExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/NewExprent.java
@@ -416,18 +416,16 @@ public class NewExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o!=null && o instanceof NewExprent) {
- NewExprent ne = (NewExprent)o;
-
- return InterpreterUtil.equalObjects(newtype, ne.getNewtype()) &&
- InterpreterUtil.equalLists(lstDims, ne.getLstDims()) &&
- InterpreterUtil.equalObjects(constructor, ne.getConstructor()) &&
- directArrayInit == ne.directArrayInit &&
- InterpreterUtil.equalLists(lstArrayElements, ne.getLstArrayElements());
-
- }
- return false;
- }
+ if(o == this) return true;
+ if(o == null || !(o instanceof NewExprent)) return false;
+
+ NewExprent ne = (NewExprent)o;
+ return InterpreterUtil.equalObjects(newtype, ne.getNewtype()) &&
+ InterpreterUtil.equalLists(lstDims, ne.getLstDims()) &&
+ InterpreterUtil.equalObjects(constructor, ne.getConstructor()) &&
+ directArrayInit == ne.directArrayInit &&
+ InterpreterUtil.equalLists(lstArrayElements, ne.getLstArrayElements());
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == constructor) {
diff --git a/src/de/fernflower/modules/decompiler/exps/SwitchExprent.java b/src/de/fernflower/modules/decompiler/exps/SwitchExprent.java
index e830e79..31b7af0 100644
--- a/src/de/fernflower/modules/decompiler/exps/SwitchExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/SwitchExprent.java
@@ -81,14 +81,12 @@ public class SwitchExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o!=null && o instanceof SwitchExprent) {
- SwitchExprent sw = (SwitchExprent)o;
-
- return InterpreterUtil.equalObjects(value, sw.getValue());
-
- }
- return false;
- }
+ if(o == this) return true;
+ if(o == null || !(o instanceof SwitchExprent)) return false;
+
+ SwitchExprent sw = (SwitchExprent)o;
+ return InterpreterUtil.equalObjects(value, sw.getValue());
+ }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == value) {
diff --git a/src/de/fernflower/modules/decompiler/exps/VarExprent.java b/src/de/fernflower/modules/decompiler/exps/VarExprent.java
index 82cba29..12710c5 100644
--- a/src/de/fernflower/modules/decompiler/exps/VarExprent.java
+++ b/src/de/fernflower/modules/decompiler/exps/VarExprent.java
@@ -122,16 +122,14 @@ public class VarExprent extends Exprent {
}
public boolean equals(Object o) {
- if(o!=null && o instanceof VarExprent) {
- VarExprent ve = (VarExprent)o;
-
- return index == ve.getIndex() &&
- version == ve.getVersion() &&
- InterpreterUtil.equalObjects(getVartype(), ve.getVartype()); // FIXME: vartype comparison redundant?
-
- }
- return false;
- }
+ if(o == this) return true;
+ if(o == null || !(o instanceof VarExprent)) return false;
+
+ VarExprent ve = (VarExprent)o;
+ return index == ve.getIndex() &&
+ version == ve.getVersion() &&
+ InterpreterUtil.equalObjects(getVartype(), ve.getVartype()); // FIXME: vartype comparison redundant?
+ }
public int getIndex() {
return index;
diff --git a/src/de/fernflower/modules/decompiler/sforms/FlattenStatementsHelper.java b/src/de/fernflower/modules/decompiler/sforms/FlattenStatementsHelper.java
index b73a45e..41b12f8 100644
--- a/src/de/fernflower/modules/decompiler/sforms/FlattenStatementsHelper.java
+++ b/src/de/fernflower/modules/decompiler/sforms/FlattenStatementsHelper.java
@@ -494,23 +494,20 @@ public class FlattenStatementsHelper {
}
@Override
- public boolean equals(Object arg0) {
-
- if(arg0 != null && arg0 instanceof FinallyPathWrapper) {
- FinallyPathWrapper fpwrapper = (FinallyPathWrapper)arg0;
-
- return (source+":"+destination+":"+entry).equals(
- fpwrapper.source+":"+fpwrapper.destination+":"+fpwrapper.entry);
- }
-
- return false;
- }
+ public boolean equals(Object o) {
+ if(o == this) return true;
+ if(o == null || !(o instanceof FinallyPathWrapper)) return false;
+
+ FinallyPathWrapper fpw = (FinallyPathWrapper)o;
+ return (source+":"+destination+":"+entry).equals(fpw.source+":"+fpw.destination+":"+fpw.entry);
+ }
@Override
public int hashCode() {
return (source+":"+destination+":"+entry).hashCode();
}
-
+
+ @Override
public String toString() {
return source + "->(" + entry + ")->" + destination;
}
diff --git a/src/de/fernflower/modules/decompiler/vars/VarVersionEdge.java b/src/de/fernflower/modules/decompiler/vars/VarVersionEdge.java
index aaedb2d..01d04af 100644
--- a/src/de/fernflower/modules/decompiler/vars/VarVersionEdge.java
+++ b/src/de/fernflower/modules/decompiler/vars/VarVersionEdge.java
@@ -35,14 +35,11 @@ public class VarVersionEdge { // FIXME: can be removed?
}
@Override
- public boolean equals(Object arg0) {
-
- if(arg0 == null || !(arg0 instanceof VarVersionEdge)) {
- return false;
- }
-
- VarVersionEdge edge = (VarVersionEdge)arg0;
-
+ public boolean equals(Object o) {
+ if(o == this) return true;
+ if(o == null || !(o instanceof VarVersionEdge)) return false;
+
+ VarVersionEdge edge = (VarVersionEdge)o;
return type == edge.type && source == edge.source && dest == edge.dest;
}
diff --git a/src/de/fernflower/modules/decompiler/vars/VarVersionPaar.java b/src/de/fernflower/modules/decompiler/vars/VarVersionPaar.java
index b40ce51..3b78505 100644
--- a/src/de/fernflower/modules/decompiler/vars/VarVersionPaar.java
+++ b/src/de/fernflower/modules/decompiler/vars/VarVersionPaar.java
@@ -39,14 +39,12 @@ public class VarVersionPaar {
}
@Override
- public boolean equals(Object arg0) {
- if(arg0 == null || !(arg0 instanceof VarVersionPaar)) {
- return false;
- }
-
- VarVersionPaar paar = (VarVersionPaar)arg0;
+ public boolean equals(Object o) {
+ if(o == this) return true;
+ if(o == null || !(o instanceof VarVersionPaar)) return false;
- return var == paar.var && version == paar.version;
+ VarVersionPaar paar = (VarVersionPaar)o;
+ return var == paar.var && version == paar.version;
}
@Override
diff --git a/src/de/fernflower/struct/consts/LinkConstant.java b/src/de/fernflower/struct/consts/LinkConstant.java
index ec0a629..66d6531 100644
--- a/src/de/fernflower/struct/consts/LinkConstant.java
+++ b/src/de/fernflower/struct/consts/LinkConstant.java
@@ -103,27 +103,16 @@ public class LinkConstant extends PooledConstant {
}
- public boolean equals(Object obj) {
+ public boolean equals(Object o) {
+ if(o == this) return true;
+ if(o == null || !(o instanceof LinkConstant)) return false;
- if(obj == null || !(obj instanceof LinkConstant)) {
- return false;
- }
-
- LinkConstant cn = (LinkConstant)obj;
-
- if(this.type == cn.type &&
- this.elementname.equals(cn.elementname) &&
- this.descriptor.equals(cn.descriptor)) {
-
- if(this.type == CONSTANT_NameAndType) {
- return this.classname.equals(cn.classname);
- } else {
- return true;
- }
- }
-
- return false;
- }
+ LinkConstant cn = (LinkConstant)o;
+ return this.type == cn.type &&
+ this.elementname.equals(cn.elementname) &&
+ this.descriptor.equals(cn.descriptor) &&
+ (this.type != CONSTANT_NameAndType || this.classname.equals(cn.classname));
+ }
// *****************************************************************************
// private methods
diff --git a/src/de/fernflower/struct/consts/PrimitiveConstant.java b/src/de/fernflower/struct/consts/PrimitiveConstant.java
index e9f949c..0532822 100644
--- a/src/de/fernflower/struct/consts/PrimitiveConstant.java
+++ b/src/de/fernflower/struct/consts/PrimitiveConstant.java
@@ -17,8 +17,6 @@ package de.fernflower.struct.consts;
import java.io.DataOutputStream;
import java.io.IOException;
-import de.fernflower.code.CodeConstants;
-
/*
* Integer, Long, Float, Double, String, Class, UTF8
*/
@@ -107,15 +105,12 @@ public class PrimitiveConstant extends PooledConstant {
}
}
- public boolean equals(Object obj) {
-
- if(obj == null || !(obj instanceof PrimitiveConstant)) {
- return false;
- }
-
- PrimitiveConstant cn = (PrimitiveConstant)obj;
+ public boolean equals(Object o) {
+ if(o == this) return true;
+ if(o == null || !(o instanceof PrimitiveConstant)) return false;
- return this.type == cn.type &&
+ PrimitiveConstant cn = (PrimitiveConstant)o;
+ return this.type == cn.type &&
this.isArray == cn.isArray &&
this.value.equals(cn.value);
diff --git a/src/de/fernflower/struct/gen/FieldDescriptor.java b/src/de/fernflower/struct/gen/FieldDescriptor.java
index 0c49b21..b2669f6 100644
--- a/src/de/fernflower/struct/gen/FieldDescriptor.java
+++ b/src/de/fernflower/struct/gen/FieldDescriptor.java
@@ -43,15 +43,12 @@ public class FieldDescriptor {
@Override
public boolean equals(Object o) {
-
- if(o!=null && o instanceof FieldDescriptor) {
- FieldDescriptor fd = (FieldDescriptor)o;
+ if(o == this) return true;
+ if(o == null || !(o instanceof FieldDescriptor)) return false;
- return type.equals(fd.type);
-
- }
- return false;
- }
+ FieldDescriptor fd = (FieldDescriptor)o;
+ return type.equals(fd.type);
+ }
@Override
public int hashCode() {
diff --git a/src/de/fernflower/struct/gen/MethodDescriptor.java b/src/de/fernflower/struct/gen/MethodDescriptor.java
index a869a85..bb1be09 100644
--- a/src/de/fernflower/struct/gen/MethodDescriptor.java
+++ b/src/de/fernflower/struct/gen/MethodDescriptor.java
@@ -15,6 +15,7 @@
package de.fernflower.struct.gen;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
public class MethodDescriptor {
@@ -84,27 +85,18 @@ public class MethodDescriptor {
@Override
public boolean equals(Object o) {
-
- if(o!=null && o instanceof MethodDescriptor) {
- MethodDescriptor md = (MethodDescriptor)o;
+ if(o == this) return true;
+ if(o == null || !(o instanceof MethodDescriptor)) return false;
- if(ret.equals(md.ret) && params.length ==md.params.length) {
- for(int i=0;i<params.length;i++) {
- if(!params[i].equals(md.params[i])) {
- return false;
- }
- }
-
- return true;
- }
-
- }
- return false;
- }
+ MethodDescriptor md = (MethodDescriptor)o;
+ return ret.equals(md.ret) && Arrays.equals(params, md.params);
+ }
@Override
public int hashCode() {
- return ret.hashCode();
+ int result = ret.hashCode();
+ result = 31 * result + params.length;
+ return result;
}
-
+
}
diff --git a/src/de/fernflower/struct/gen/VarType.java b/src/de/fernflower/struct/gen/VarType.java
index a8e40d4..c01bcf1 100644
--- a/src/de/fernflower/struct/gen/VarType.java
+++ b/src/de/fernflower/struct/gen/VarType.java
@@ -231,14 +231,12 @@ public class VarType { // TODO: optimize switch
}
}
- public boolean equals(Object arg0) {
-
- if(arg0 == null || !(arg0 instanceof VarType)) {
- return false;
- }
- VarType vt = (VarType)arg0;
-
- return type == vt.type && arraydim == vt.arraydim &&
+ public boolean equals(Object o) {
+ if(o == this) return true;
+ if(o == null || !(o instanceof VarType)) return false;
+
+ VarType vt = (VarType)o;
+ return type == vt.type && arraydim == vt.arraydim &&
InterpreterUtil.equalObjects(value, vt.value);
}
diff --git a/src/de/fernflower/util/FastFixedSetFactory.java b/src/de/fernflower/util/FastFixedSetFactory.java
index fb26c04..1340376 100644
--- a/src/de/fernflower/util/FastFixedSetFactory.java
+++ b/src/de/fernflower/util/FastFixedSetFactory.java
@@ -176,13 +176,11 @@ public class FastFixedSetFactory<E> {
}
- public boolean equals(Object obj) {
+ public boolean equals(Object o) {
+ if(o == this) return true;
+ if(o == null || !(o instanceof FastFixedSet)) return false;
- if(!(obj instanceof FastFixedSet)) {
- return false;
- }
-
- int[] extdata = ((FastFixedSet<E>)obj).getData();
+ int[] extdata = ((FastFixedSet)o).getData();
int[] intdata = data;
for(int i=intdata.length-1;i>=0;i--) {
diff --git a/src/de/fernflower/util/FastSetFactory.java b/src/de/fernflower/util/FastSetFactory.java
index 9fc3550..7543e0d 100644
--- a/src/de/fernflower/util/FastSetFactory.java
+++ b/src/de/fernflower/util/FastSetFactory.java
@@ -284,13 +284,11 @@ public class FastSetFactory<E> {
}
- public boolean equals(Object obj) {
+ public boolean equals(Object o) {
+ if(o == this) return true;
+ if(o == null || !(o instanceof FastSet)) return false;
- if(!(obj instanceof FastSet)) {
- return false;
- }
-
- int[] longdata = ((FastSet<E>)obj).getData();
+ int[] longdata = ((FastSet)o).getData();
int[] shortdata = data;
if(data.length > longdata.length) {
diff --git a/src/de/fernflower/util/FastSparseSetFactory.java b/src/de/fernflower/util/FastSparseSetFactory.java
index ae2948e..b0b8b26 100644
--- a/src/de/fernflower/util/FastSparseSetFactory.java
+++ b/src/de/fernflower/util/FastSparseSetFactory.java
@@ -350,13 +350,11 @@ public class FastSparseSetFactory<E> {
}
- public boolean equals(Object obj) {
+ public boolean equals(Object o) {
+ if(o == this) return true;
+ if(o == null || !(o instanceof FastSparseSet)) return false;
- if(!(obj instanceof FastSparseSet)) {
- return false;
- }
-
- int[] longdata = ((FastSparseSet<E>)obj).getData();
+ int[] longdata = ((FastSparseSet)o).getData();
int[] shortdata = data;
if(data.length > longdata.length) {