Skip to content

Commit

Permalink
Simplify ImmutableSeqs.CopiesSeq
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed Jan 5, 2025
1 parent e0a3956 commit a214a88
Showing 1 changed file with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1160,27 +1160,12 @@ static final class CopiesSeq<E> extends CopiesSeqBase<E> implements ImmutableSeq

@Override
public int hashCode() {
if (value == null) {
return SEQ_HASH_MAGIC;
}
final int vh = value.hashCode();
if (vh == 0) {
return SEQ_HASH_MAGIC;
}

int h = 0;
for (int i = 0; i < size; i++) {
h = h * 31 + vh;
}
return h + SEQ_HASH_MAGIC;
return Seq.hashCode(this);
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Seq<?> other)) {
return false;
}
return Seq.equals(this, other);
return obj instanceof Seq<?> other && Seq.equals(this, other);
}
}

Expand Down

0 comments on commit a214a88

Please sign in to comment.