@@ -96,12 +96,8 @@ private static int hashCode(InternalByteArray byteArray) {
96
96
return hashCode (byteArray .getArray (), byteArray .getOffset (), byteArray .getLength ());
97
97
}
98
98
99
- // A variant of <code> Arrays. hashCode</code> that allows for selecting a range within the array.
99
+ /** A variant of {@link Arrays# hashCode(byte[])} that allows for selecting a range within the array. */
100
100
private static int hashCode (byte [] bytes , int offset , int length ) {
101
- if (bytes == null ) {
102
- return 0 ;
103
- }
104
-
105
101
int result = 1 ;
106
102
for (int i = offset ; i < offset + length ; i ++) {
107
103
result = 31 * result + bytes [i ];
@@ -124,7 +120,7 @@ private boolean isPerfectFit() {
124
120
* cache hit. To avoid incurring that cost unnecessarily, we allow cache keys to refer to a subset of a byte array.
125
121
* While that saves computation during a cache lookup, it means such keys are unsuitable for insertion into the
126
122
* cache. This method makes a key we can use safely for insertion.
127
- *
123
+ * <p>
128
124
* If we know that the key refers to an immutable byte array and the key does not refer to a substring, we can
129
125
* safely refer to the original byte array without needing to make an additional copy.
130
126
*
@@ -135,7 +131,7 @@ public TBytesKey makeCacheable(boolean isImmutable) {
135
131
return this ;
136
132
}
137
133
138
- // Make a copy of the substring's bytes so we can cache them without retaining the original byte array.
134
+ // Make a copy of the substring's bytes so we can cache them without retaining the larger original byte array.
139
135
var resolvedSubstring = ArrayUtils .extractRange (this .bytes , this .offset , this .offset + this .length );
140
136
141
137
return new TBytesKey (resolvedSubstring , encoding );
0 commit comments