minor optimization (o == this in equals)

master
Roman Shevchenko 11 years ago
parent e39ae1e71d
commit 879330b555
  1. 10
      src/de/fernflower/main/rels/NestedClassProcessor.java
  2. 6
      src/de/fernflower/modules/decompiler/exps/AnnotationExprent.java
  3. 6
      src/de/fernflower/modules/decompiler/exps/ArrayExprent.java
  4. 8
      src/de/fernflower/modules/decompiler/exps/AssignmentExprent.java
  5. 7
      src/de/fernflower/modules/decompiler/exps/ConstExprent.java
  6. 7
      src/de/fernflower/modules/decompiler/exps/ExitExprent.java
  7. 8
      src/de/fernflower/modules/decompiler/exps/FieldExprent.java
  8. 7
      src/de/fernflower/modules/decompiler/exps/FunctionExprent.java
  9. 8
      src/de/fernflower/modules/decompiler/exps/IfExprent.java
  10. 8
      src/de/fernflower/modules/decompiler/exps/InvocationExprent.java
  11. 7
      src/de/fernflower/modules/decompiler/exps/MonitorExprent.java
  12. 8
      src/de/fernflower/modules/decompiler/exps/NewExprent.java
  13. 8
      src/de/fernflower/modules/decompiler/exps/SwitchExprent.java
  14. 8
      src/de/fernflower/modules/decompiler/exps/VarExprent.java
  15. 15
      src/de/fernflower/modules/decompiler/sforms/FlattenStatementsHelper.java
  16. 11
      src/de/fernflower/modules/decompiler/vars/VarVersionEdge.java
  17. 10
      src/de/fernflower/modules/decompiler/vars/VarVersionPaar.java
  18. 25
      src/de/fernflower/struct/consts/LinkConstant.java
  19. 13
      src/de/fernflower/struct/consts/PrimitiveConstant.java
  20. 7
      src/de/fernflower/struct/gen/FieldDescriptor.java
  21. 22
      src/de/fernflower/struct/gen/MethodDescriptor.java
  22. 10
      src/de/fernflower/struct/gen/VarType.java
  23. 10
      src/de/fernflower/util/FastFixedSetFactory.java
  24. 10
      src/de/fernflower/util/FastSetFactory.java
  25. 10
      src/de/fernflower/util/FastSparseSetFactory.java

@ -997,13 +997,11 @@ public class NestedClassProcessor {
}
@Override
public boolean equals(Object arg0) {
public boolean equals(Object o) {
if(o == this) return true;
if(o == null || !(o instanceof VarFieldPair)) return false;
if(!(arg0 instanceof VarFieldPair)) {
return false;
}
VarFieldPair pair = (VarFieldPair)arg0;
VarFieldPair pair = (VarFieldPair)o;
return keyfield.equals(pair.keyfield) && varpaar.equals(pair.varpaar);
}

@ -95,14 +95,14 @@ public class AnnotationExprent extends Exprent {
}
public boolean equals(Object o) {
if(o!=null && o instanceof AnnotationExprent) {
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);
}
return false;
}
public String getClassname() {
return classname;

@ -96,13 +96,13 @@ public class ArrayExprent extends Exprent {
}
public boolean equals(Object o) {
if(o!=null && o instanceof ArrayExprent) {
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());
}
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == array) {

@ -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) {
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();
}
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == left) {

@ -276,14 +276,13 @@ public class ConstExprent extends Exprent {
public boolean equals(Object o) {
if(o!=null && o instanceof ConstExprent) {
ConstExprent cn = (ConstExprent)o;
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());
}
return false;
}
public boolean hasBooleanValue() {

@ -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;
ExitExprent et = (ExitExprent)o;
return exittype==et.getExittype() &&
InterpreterUtil.equalObjects(value, et.getValue());
}
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == value) {

@ -155,17 +155,15 @@ public class FieldExprent extends Exprent {
}
public boolean equals(Object o) {
if(o!=null && o instanceof FieldExprent) {
FieldExprent ft = (FieldExprent)o;
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());
}
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {

@ -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;
FunctionExprent fe = (FunctionExprent)o;
return functype==fe.getFunctype() &&
InterpreterUtil.equalLists(lstOperands, fe.getLstOperands()); // TODO: order of operands insignificant
}
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
for(int i=0;i<lstOperands.size();i++) {

@ -117,13 +117,11 @@ public class IfExprent extends Exprent {
}
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;
IfExprent ie = (IfExprent)o;
return InterpreterUtil.equalObjects(condition, ie.getCondition());
}
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {

@ -393,9 +393,10 @@ public class InvocationExprent extends Exprent {
}
public boolean equals(Object o) {
if(o!=null && o instanceof InvocationExprent) {
InvocationExprent it = (InvocationExprent)o;
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() &&
@ -403,9 +404,6 @@ public class InvocationExprent extends Exprent {
InterpreterUtil.equalObjects(descriptor, it.getDescriptor()) &&
functype == it.getFunctype() &&
InterpreterUtil.equalLists(lstParameters, it.getLstParameters());
}
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {

@ -57,14 +57,13 @@ public class MonitorExprent extends Exprent {
}
public boolean equals(Object o) {
if(o!=null && o instanceof MonitorExprent) {
MonitorExprent me = (MonitorExprent)o;
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());
}
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == value) {

@ -416,17 +416,15 @@ public class NewExprent extends Exprent {
}
public boolean equals(Object o) {
if(o!=null && o instanceof NewExprent) {
NewExprent ne = (NewExprent)o;
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());
}
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {

@ -81,13 +81,11 @@ public class SwitchExprent extends Exprent {
}
public boolean equals(Object o) {
if(o!=null && o instanceof SwitchExprent) {
SwitchExprent sw = (SwitchExprent)o;
if(o == this) return true;
if(o == null || !(o instanceof SwitchExprent)) return false;
SwitchExprent sw = (SwitchExprent)o;
return InterpreterUtil.equalObjects(value, sw.getValue());
}
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) {

@ -122,15 +122,13 @@ public class VarExprent extends Exprent {
}
public boolean equals(Object o) {
if(o!=null && o instanceof VarExprent) {
VarExprent ve = (VarExprent)o;
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?
}
return false;
}
public int getIndex() {

@ -494,16 +494,12 @@ public class FlattenStatementsHelper {
}
@Override
public boolean equals(Object arg0) {
public boolean equals(Object o) {
if(o == this) return true;
if(o == null || !(o instanceof FinallyPathWrapper)) return false;
if(arg0 != null && arg0 instanceof FinallyPathWrapper) {
FinallyPathWrapper fpwrapper = (FinallyPathWrapper)arg0;
return (source+":"+destination+":"+entry).equals(
fpwrapper.source+":"+fpwrapper.destination+":"+fpwrapper.entry);
}
return false;
FinallyPathWrapper fpw = (FinallyPathWrapper)o;
return (source+":"+destination+":"+entry).equals(fpw.source+":"+fpw.destination+":"+fpw.entry);
}
@Override
@ -511,6 +507,7 @@ public class FlattenStatementsHelper {
return (source+":"+destination+":"+entry).hashCode();
}
@Override
public String toString() {
return source + "->(" + entry + ")->" + destination;
}

@ -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;
}

@ -39,13 +39,11 @@ 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;
VarVersionPaar paar = (VarVersionPaar)o;
return var == paar.var && version == paar.version;
}

@ -103,26 +103,15 @@ 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 &&
LinkConstant cn = (LinkConstant)o;
return 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;
this.descriptor.equals(cn.descriptor) &&
(this.type != CONSTANT_NameAndType || this.classname.equals(cn.classname));
}
// *****************************************************************************

@ -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,14 +105,11 @@ 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;
PrimitiveConstant cn = (PrimitiveConstant)o;
return this.type == cn.type &&
this.isArray == cn.isArray &&
this.value.equals(cn.value);

@ -43,14 +43,11 @@ public class FieldDescriptor {
@Override
public boolean equals(Object o) {
if(o == this) return true;
if(o == null || !(o instanceof FieldDescriptor)) return false;
if(o!=null && o instanceof FieldDescriptor) {
FieldDescriptor fd = (FieldDescriptor)o;
return type.equals(fd.type);
}
return false;
}
@Override

@ -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 == this) return true;
if(o == null || !(o instanceof MethodDescriptor)) return false;
if(o!=null && o instanceof MethodDescriptor) {
MethodDescriptor md = (MethodDescriptor)o;
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;
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;
}
}

@ -231,13 +231,11 @@ public class VarType { // TODO: optimize switch
}
}
public boolean equals(Object arg0) {
if(arg0 == null || !(arg0 instanceof VarType)) {
return false;
}
VarType vt = (VarType)arg0;
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);
}

@ -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--) {

@ -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) {

@ -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) {

Loading…
Cancel
Save