minor optimization (o == this in equals)

master
Roman Shevchenko 10 years ago
parent e39ae1e71d
commit 879330b555
  1. 10
      src/de/fernflower/main/rels/NestedClassProcessor.java
  2. 16
      src/de/fernflower/modules/decompiler/exps/AnnotationExprent.java
  3. 14
      src/de/fernflower/modules/decompiler/exps/ArrayExprent.java
  4. 18
      src/de/fernflower/modules/decompiler/exps/AssignmentExprent.java
  5. 13
      src/de/fernflower/modules/decompiler/exps/ConstExprent.java
  6. 13
      src/de/fernflower/modules/decompiler/exps/ExitExprent.java
  7. 22
      src/de/fernflower/modules/decompiler/exps/FieldExprent.java
  8. 13
      src/de/fernflower/modules/decompiler/exps/FunctionExprent.java
  9. 12
      src/de/fernflower/modules/decompiler/exps/IfExprent.java
  10. 26
      src/de/fernflower/modules/decompiler/exps/InvocationExprent.java
  11. 13
      src/de/fernflower/modules/decompiler/exps/MonitorExprent.java
  12. 22
      src/de/fernflower/modules/decompiler/exps/NewExprent.java
  13. 12
      src/de/fernflower/modules/decompiler/exps/SwitchExprent.java
  14. 18
      src/de/fernflower/modules/decompiler/exps/VarExprent.java
  15. 17
      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. 31
      src/de/fernflower/struct/consts/LinkConstant.java
  19. 13
      src/de/fernflower/struct/consts/PrimitiveConstant.java
  20. 13
      src/de/fernflower/struct/gen/FieldDescriptor.java
  21. 26
      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 @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)) { VarFieldPair pair = (VarFieldPair)o;
return false;
}
VarFieldPair pair = (VarFieldPair)arg0;
return keyfield.equals(pair.keyfield) && varpaar.equals(pair.varpaar); return keyfield.equals(pair.keyfield) && varpaar.equals(pair.varpaar);
} }

@ -95,14 +95,14 @@ public class AnnotationExprent extends Exprent {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof AnnotationExprent) { if(o == this) return true;
AnnotationExprent ann = (AnnotationExprent)o; if(o == null || !(o instanceof AnnotationExprent)) return false;
return classname.equals(ann.classname) &&
InterpreterUtil.equalLists(parnames, ann.parnames) && AnnotationExprent ann = (AnnotationExprent)o;
InterpreterUtil.equalLists(parvalues, ann.parvalues); return classname.equals(ann.classname) &&
} InterpreterUtil.equalLists(parnames, ann.parnames) &&
return false; InterpreterUtil.equalLists(parvalues, ann.parvalues);
} }
public String getClassname() { public String getClassname() {
return classname; return classname;

@ -96,13 +96,13 @@ public class ArrayExprent extends Exprent {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof ArrayExprent) { if(o == this) return true;
ArrayExprent arr = (ArrayExprent)o; if(o == null || !(o instanceof ArrayExprent)) return false;
return InterpreterUtil.equalObjects(array, arr.getArray()) &&
InterpreterUtil.equalObjects(index, arr.getIndex()); ArrayExprent arr = (ArrayExprent)o;
} return InterpreterUtil.equalObjects(array, arr.getArray()) &&
return false; InterpreterUtil.equalObjects(index, arr.getIndex());
} }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) { public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == array) { if(oldexpr == array) {

@ -140,20 +140,20 @@ public class AssignmentExprent extends Exprent {
buffer.append(left.toJava(indent)); 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(); return buffer.toString();
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof AssignmentExprent) { if(o == this) return true;
AssignmentExprent as = (AssignmentExprent)o; if(o == null || !(o instanceof AssignmentExprent)) return false;
return InterpreterUtil.equalObjects(left, as.getLeft()) &&
InterpreterUtil.equalObjects(right, as.getRight()) && AssignmentExprent as = (AssignmentExprent)o;
condtype == as.getCondtype(); return InterpreterUtil.equalObjects(left, as.getLeft()) &&
} InterpreterUtil.equalObjects(right, as.getRight()) &&
return false; condtype == as.getCondtype();
} }
public void replaceExprent(Exprent oldexpr, Exprent newexpr) { public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == left) { if(oldexpr == left) {

@ -276,14 +276,13 @@ public class ConstExprent extends Exprent {
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof ConstExprent) { if(o == this) return true;
ConstExprent cn = (ConstExprent)o; if(o == null || !(o instanceof ConstExprent)) return false;
return InterpreterUtil.equalObjects(consttype, cn.getConsttype()) && ConstExprent cn = (ConstExprent)o;
InterpreterUtil.equalObjects(value, cn.getValue()); return InterpreterUtil.equalObjects(consttype, cn.getConsttype()) &&
} InterpreterUtil.equalObjects(value, cn.getValue());
return false; }
}
public boolean hasBooleanValue() { public boolean hasBooleanValue() {

@ -120,14 +120,13 @@ public class ExitExprent extends Exprent {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof ExitExprent) { if(o == this) return true;
ExitExprent et = (ExitExprent)o; if(o == null || !(o instanceof ExitExprent)) return false;
return exittype==et.getExittype() && ExitExprent et = (ExitExprent)o;
InterpreterUtil.equalObjects(value, et.getValue()); return exittype==et.getExittype() &&
} InterpreterUtil.equalObjects(value, et.getValue());
return false; }
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) { public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == value) { if(oldexpr == value) {

@ -155,18 +155,16 @@ public class FieldExprent extends Exprent {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof FieldExprent) { if(o == this) return true;
FieldExprent ft = (FieldExprent)o; if(o == null || !(o instanceof FieldExprent)) return false;
return InterpreterUtil.equalObjects(name, ft.getName()) && FieldExprent ft = (FieldExprent)o;
InterpreterUtil.equalObjects(classname, ft.getClassname()) && return InterpreterUtil.equalObjects(name, ft.getName()) &&
isStatic == ft.isStatic() && InterpreterUtil.equalObjects(classname, ft.getClassname()) &&
InterpreterUtil.equalObjects(instance, ft.getInstance()) && isStatic == ft.isStatic() &&
InterpreterUtil.equalObjects(descriptor, ft.getDescriptor()); InterpreterUtil.equalObjects(instance, ft.getInstance()) &&
InterpreterUtil.equalObjects(descriptor, ft.getDescriptor());
} }
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) { public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == instance) { if(oldexpr == instance) {

@ -429,14 +429,13 @@ public class FunctionExprent extends Exprent {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof FunctionExprent) { if(o == this) return true;
FunctionExprent fe = (FunctionExprent)o; if(o == null || !(o instanceof FunctionExprent)) return false;
return functype==fe.getFunctype() && FunctionExprent fe = (FunctionExprent)o;
InterpreterUtil.equalLists(lstOperands, fe.getLstOperands()); // TODO: order of operands insignificant return functype==fe.getFunctype() &&
} InterpreterUtil.equalLists(lstOperands, fe.getLstOperands()); // TODO: order of operands insignificant
return false; }
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) { public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
for(int i=0;i<lstOperands.size();i++) { for(int i=0;i<lstOperands.size();i++) {

@ -117,14 +117,12 @@ public class IfExprent extends Exprent {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof IfExprent) { if(o == this) return true;
IfExprent ie = (IfExprent)o; if(o == null || !(o instanceof IfExprent)) return false;
return InterpreterUtil.equalObjects(condition, ie.getCondition()); IfExprent ie = (IfExprent)o;
return InterpreterUtil.equalObjects(condition, ie.getCondition());
} }
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) { public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == condition) { if(oldexpr == condition) {

@ -393,20 +393,18 @@ public class InvocationExprent extends Exprent {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof InvocationExprent) { if(o == this) return true;
InvocationExprent it = (InvocationExprent)o; if(o == null || !(o instanceof InvocationExprent)) return false;
return InterpreterUtil.equalObjects(name, it.getName()) && InvocationExprent it = (InvocationExprent)o;
InterpreterUtil.equalObjects(classname, it.getClassname()) && return InterpreterUtil.equalObjects(name, it.getName()) &&
isStatic == it.isStatic() && InterpreterUtil.equalObjects(classname, it.getClassname()) &&
InterpreterUtil.equalObjects(instance, it.getInstance()) && isStatic == it.isStatic() &&
InterpreterUtil.equalObjects(descriptor, it.getDescriptor()) && InterpreterUtil.equalObjects(instance, it.getInstance()) &&
functype == it.getFunctype() && InterpreterUtil.equalObjects(descriptor, it.getDescriptor()) &&
InterpreterUtil.equalLists(lstParameters, it.getLstParameters()); functype == it.getFunctype() &&
InterpreterUtil.equalLists(lstParameters, it.getLstParameters());
} }
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) { public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == instance) { if(oldexpr == instance) {

@ -57,14 +57,13 @@ public class MonitorExprent extends Exprent {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof MonitorExprent) { if(o == this) return true;
MonitorExprent me = (MonitorExprent)o; if(o == null || !(o instanceof MonitorExprent)) return false;
return montype == me.getMontype() && MonitorExprent me = (MonitorExprent)o;
InterpreterUtil.equalObjects(value, me.getValue()); return montype == me.getMontype() &&
} InterpreterUtil.equalObjects(value, me.getValue());
return false; }
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) { public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == value) { if(oldexpr == value) {

@ -416,18 +416,16 @@ public class NewExprent extends Exprent {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof NewExprent) { if(o == this) return true;
NewExprent ne = (NewExprent)o; if(o == null || !(o instanceof NewExprent)) return false;
return InterpreterUtil.equalObjects(newtype, ne.getNewtype()) && NewExprent ne = (NewExprent)o;
InterpreterUtil.equalLists(lstDims, ne.getLstDims()) && return InterpreterUtil.equalObjects(newtype, ne.getNewtype()) &&
InterpreterUtil.equalObjects(constructor, ne.getConstructor()) && InterpreterUtil.equalLists(lstDims, ne.getLstDims()) &&
directArrayInit == ne.directArrayInit && InterpreterUtil.equalObjects(constructor, ne.getConstructor()) &&
InterpreterUtil.equalLists(lstArrayElements, ne.getLstArrayElements()); directArrayInit == ne.directArrayInit &&
InterpreterUtil.equalLists(lstArrayElements, ne.getLstArrayElements());
} }
return false;
}
public void replaceExprent(Exprent oldexpr, Exprent newexpr) { public void replaceExprent(Exprent oldexpr, Exprent newexpr) {
if(oldexpr == constructor) { if(oldexpr == constructor) {

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

@ -122,16 +122,14 @@ public class VarExprent extends Exprent {
} }
public boolean equals(Object o) { public boolean equals(Object o) {
if(o!=null && o instanceof VarExprent) { if(o == this) return true;
VarExprent ve = (VarExprent)o; if(o == null || !(o instanceof VarExprent)) return false;
return index == ve.getIndex() && VarExprent ve = (VarExprent)o;
version == ve.getVersion() && return index == ve.getIndex() &&
InterpreterUtil.equalObjects(getVartype(), ve.getVartype()); // FIXME: vartype comparison redundant? version == ve.getVersion() &&
InterpreterUtil.equalObjects(getVartype(), ve.getVartype()); // FIXME: vartype comparison redundant?
} }
return false;
}
public int getIndex() { public int getIndex() {
return index; return index;

@ -494,23 +494,20 @@ public class FlattenStatementsHelper {
} }
@Override @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 fpw = (FinallyPathWrapper)o;
FinallyPathWrapper fpwrapper = (FinallyPathWrapper)arg0; return (source+":"+destination+":"+entry).equals(fpw.source+":"+fpw.destination+":"+fpw.entry);
}
return (source+":"+destination+":"+entry).equals(
fpwrapper.source+":"+fpwrapper.destination+":"+fpwrapper.entry);
}
return false;
}
@Override @Override
public int hashCode() { public int hashCode() {
return (source+":"+destination+":"+entry).hashCode(); return (source+":"+destination+":"+entry).hashCode();
} }
@Override
public String toString() { public String toString() {
return source + "->(" + entry + ")->" + destination; return source + "->(" + entry + ")->" + destination;
} }

@ -35,14 +35,11 @@ public class VarVersionEdge { // FIXME: can be removed?
} }
@Override @Override
public boolean equals(Object arg0) { public boolean equals(Object o) {
if(o == this) return true;
if(arg0 == null || !(arg0 instanceof VarVersionEdge)) { if(o == null || !(o instanceof VarVersionEdge)) return false;
return false;
}
VarVersionEdge edge = (VarVersionEdge)arg0;
VarVersionEdge edge = (VarVersionEdge)o;
return type == edge.type && source == edge.source && dest == edge.dest; return type == edge.type && source == edge.source && dest == edge.dest;
} }

@ -39,13 +39,11 @@ public class VarVersionPaar {
} }
@Override @Override
public boolean equals(Object arg0) { public boolean equals(Object o) {
if(arg0 == null || !(arg0 instanceof VarVersionPaar)) { if(o == this) return true;
return false; if(o == null || !(o instanceof VarVersionPaar)) return false;
}
VarVersionPaar paar = (VarVersionPaar)arg0;
VarVersionPaar paar = (VarVersionPaar)o;
return var == paar.var && version == paar.version; return var == paar.var && version == paar.version;
} }

@ -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(obj == null || !(obj instanceof LinkConstant)) { if(o == null || !(o instanceof LinkConstant)) return false;
return false;
} LinkConstant cn = (LinkConstant)o;
return this.type == cn.type &&
LinkConstant cn = (LinkConstant)obj; this.elementname.equals(cn.elementname) &&
this.descriptor.equals(cn.descriptor) &&
if(this.type == cn.type && (this.type != CONSTANT_NameAndType || this.classname.equals(cn.classname));
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;
}
// ***************************************************************************** // *****************************************************************************
// private methods // private methods

@ -17,8 +17,6 @@ package de.fernflower.struct.consts;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import de.fernflower.code.CodeConstants;
/* /*
* Integer, Long, Float, Double, String, Class, UTF8 * Integer, Long, Float, Double, String, Class, UTF8
*/ */
@ -107,14 +105,11 @@ public class PrimitiveConstant extends PooledConstant {
} }
} }
public boolean equals(Object obj) { public boolean equals(Object o) {
if(o == this) return true;
if(obj == null || !(obj instanceof PrimitiveConstant)) { if(o == null || !(o instanceof PrimitiveConstant)) return false;
return false;
}
PrimitiveConstant cn = (PrimitiveConstant)obj;
PrimitiveConstant cn = (PrimitiveConstant)o;
return this.type == cn.type && return this.type == cn.type &&
this.isArray == cn.isArray && this.isArray == cn.isArray &&
this.value.equals(cn.value); this.value.equals(cn.value);

@ -43,15 +43,12 @@ public class FieldDescriptor {
@Override @Override
public boolean equals(Object o) { 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;
FieldDescriptor fd = (FieldDescriptor)o; return type.equals(fd.type);
}
return type.equals(fd.type);
}
return false;
}
@Override @Override
public int hashCode() { public int hashCode() {

@ -15,6 +15,7 @@
package de.fernflower.struct.gen; package de.fernflower.struct.gen;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class MethodDescriptor { public class MethodDescriptor {
@ -84,27 +85,18 @@ public class MethodDescriptor {
@Override @Override
public boolean equals(Object o) { 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;
MethodDescriptor md = (MethodDescriptor)o; return ret.equals(md.ret) && Arrays.equals(params, md.params);
}
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;
}
@Override @Override
public int hashCode() { 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) { public boolean equals(Object o) {
if(o == this) return true;
if(arg0 == null || !(arg0 instanceof VarType)) { if(o == null || !(o instanceof VarType)) return false;
return false;
}
VarType vt = (VarType)arg0;
VarType vt = (VarType)o;
return type == vt.type && arraydim == vt.arraydim && return type == vt.type && arraydim == vt.arraydim &&
InterpreterUtil.equalObjects(value, vt.value); 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)) { int[] extdata = ((FastFixedSet)o).getData();
return false;
}
int[] extdata = ((FastFixedSet<E>)obj).getData();
int[] intdata = data; int[] intdata = data;
for(int i=intdata.length-1;i>=0;i--) { 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)) { int[] longdata = ((FastSet)o).getData();
return false;
}
int[] longdata = ((FastSet<E>)obj).getData();
int[] shortdata = data; int[] shortdata = data;
if(data.length > longdata.length) { 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)) { int[] longdata = ((FastSparseSet)o).getData();
return false;
}
int[] longdata = ((FastSparseSet<E>)obj).getData();
int[] shortdata = data; int[] shortdata = data;
if(data.length > longdata.length) { if(data.length > longdata.length) {

Loading…
Cancel
Save