more small optimizations
This commit is contained in:
parent
1c2f25dd0f
commit
7de072b14e
|
@ -51,15 +51,11 @@ public class PlainShardIterator extends PlainShardsIterator implements ShardIter
|
|||
|
||||
@Override public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
ShardIterator that = (ShardIterator) o;
|
||||
|
||||
if (shardId != null ? !shardId.equals(that.shardId()) : that.shardId() != null) return false;
|
||||
|
||||
return true;
|
||||
return shardId.equals(that.shardId());
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return shardId != null ? shardId.hashCode() : 0;
|
||||
return shardId.hashCode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,17 +57,13 @@ public class Index implements Serializable, Streamable {
|
|||
|
||||
@Override public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
if (o == null) return false;
|
||||
Index index1 = (Index) o;
|
||||
|
||||
if (name != null ? !name.equals(index1.name) : index1.name != null) return false;
|
||||
|
||||
return true;
|
||||
return name.equals(index1.name);
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return name != null ? name.hashCode() : 0;
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
public static Index readIndexName(StreamInput in) throws IOException {
|
||||
|
|
|
@ -40,6 +40,8 @@ public class ShardId implements Serializable, Streamable {
|
|||
|
||||
private int shardId;
|
||||
|
||||
private int hashCode;
|
||||
|
||||
private ShardId() {
|
||||
|
||||
}
|
||||
|
@ -51,6 +53,7 @@ public class ShardId implements Serializable, Streamable {
|
|||
public ShardId(Index index, int shardId) {
|
||||
this.index = index;
|
||||
this.shardId = shardId;
|
||||
this.hashCode = computeHashCode();
|
||||
}
|
||||
|
||||
public Index index() {
|
||||
|
@ -75,17 +78,16 @@ public class ShardId implements Serializable, Streamable {
|
|||
|
||||
@Override public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
if (o == null) return false;
|
||||
ShardId shardId1 = (ShardId) o;
|
||||
|
||||
if (shardId != shardId1.shardId) return false;
|
||||
if (index != null ? !index.equals(shardId1.index) : shardId1.index != null) return false;
|
||||
|
||||
return true;
|
||||
return shardId == shardId1.shardId && index.name().equals(shardId1.index.name());
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
private int computeHashCode() {
|
||||
int result = index != null ? index.hashCode() : 0;
|
||||
result = 31 * result + shardId;
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue