Avoid calling getClass() in equals(). It disturbs profiling

This commit is contained in:
Andrey Breslav
2013-05-02 10:14:06 +02:00
committed by Alexander Udalov
parent 1472499874
commit 187bf8abfe
2 changed files with 6 additions and 8 deletions
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class FqName extends FqNameBase { public final class FqName extends FqNameBase {
@NotNull @NotNull
public static FqName fromSegments(@NotNull List<String> names) { public static FqName fromSegments(@NotNull List<String> names) {
@@ -156,7 +156,7 @@ public class FqName extends FqNameBase {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (!(o instanceof FqName)) return false;
FqName otherFqName = (FqName) o; FqName otherFqName = (FqName) o;
@@ -25,7 +25,7 @@ import java.util.List;
/** /**
* Like {@link FqName} but allows '<' and '>' characters in name. * Like {@link FqName} but allows '<' and '>' characters in name.
*/ */
public class FqNameUnsafe extends FqNameBase { public final class FqNameUnsafe extends FqNameBase {
public static final Name ROOT_NAME = Name.special("<root>"); public static final Name ROOT_NAME = Name.special("<root>");
@@ -265,20 +265,18 @@ public class FqNameUnsafe extends FqNameBase {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
// generated by Idea
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (!(o instanceof FqNameUnsafe)) return false;
FqNameUnsafe that = (FqNameUnsafe) o; FqNameUnsafe that = (FqNameUnsafe) o;
if (fqName != null ? !fqName.equals(that.fqName) : that.fqName != null) return false; if (!fqName.equals(that.fqName)) return false;
return true; return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
// generated by Idea return fqName.hashCode();
return fqName != null ? fqName.hashCode() : 0;
} }
} }