ByteSequence: proper equals and hasCode

This commit is contained in:
Dmitry Batkovich
2016-09-13 10:44:07 +03:00
parent 3b95f97cb0
commit f3719d7cd5
@@ -60,7 +60,7 @@ public class ByteSequence {
final byte[] thisBytes = myBytes;
final byte[] thatBytes = sequence.myBytes;
for (int i = 0, j = myOffset, k = sequence.myOffset; i < len; i++) {
for (int i = 0, j = myOffset, k = sequence.myOffset; i < len; i++, j++, k++) {
if (thisBytes[j] != thatBytes[k]) {
return false;
}
@@ -75,8 +75,8 @@ public class ByteSequence {
final byte[] thisBytes = myBytes;
int result = 1;
for (int i = 0, j = myOffset; i < len; i++) {
result = result * 31 + thisBytes[j];
for (int i = myOffset; i < myOffset + len; i++) {
result = result * 31 + thisBytes[i];
}
return result;
}