1
1
/*
2
- * Copyright (c) 2018, 2024 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2018, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* The Universal Permissive License (UPL), Version 1.0
@@ -83,8 +83,7 @@ public byte[] toByteArray() {
83
83
public boolean equals (Object obj ) {
84
84
if (this == obj ) {
85
85
return true ;
86
- } else if (obj instanceof ByteArraySequence ) {
87
- ByteArraySequence other = ((ByteArraySequence ) obj );
86
+ } else if (obj instanceof ByteArraySequence other ) {
88
87
if (buffer == other .buffer ) {
89
88
return start == other .start && length == other .length ;
90
89
}
@@ -97,15 +96,10 @@ public boolean equals(Object obj) {
97
96
// hash was already computed and hash is not equal
98
97
return false ;
99
98
}
100
- int otherStart = other .start ;
101
- for (int i = 0 ; i < length ; i ++) {
102
- if (buffer [start + i ] != other .buffer [otherStart + i ]) {
103
- return false ;
104
- }
105
- }
106
- return true ;
107
- } else if (obj instanceof ByteSequence ) {
108
- ByteSequence other = ((ByteSequence ) obj );
99
+ return Arrays .equals (
100
+ this .buffer , this .start , this .start + this .length ,
101
+ other .buffer , other .start , other .start + other .length );
102
+ } else if (obj instanceof ByteSequence other ) {
109
103
if (length != other .length ()) {
110
104
return false ;
111
105
}
0 commit comments