Skip to content

Commit 087d831

Browse files
committed
Remove unnecessary checkIndex method
1 parent 17749e2 commit 087d831

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

src/main/java/com/maxmind/db/SingleBuffer.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,6 @@ private SingleBuffer(ByteBuffer buffer) {
4242
this.buffer = buffer;
4343
}
4444

45-
/**
46-
* Validates and converts a long index to an int for use with
47-
* {@link ByteBuffer}.
48-
*
49-
* @param index the index to check
50-
* @return the index as an int
51-
* @throws IndexOutOfBoundsException if the index is negative or exceeds
52-
* {@link Integer#MAX_VALUE}
53-
*/
54-
private int checkIndex(long index) {
55-
if (index < 0 || index > Integer.MAX_VALUE) {
56-
throw new IndexOutOfBoundsException(
57-
"Index out of bounds for SingleBuffer: " + index
58-
);
59-
}
60-
return (int) index;
61-
}
62-
6345
/** {@inheritDoc} */
6446
@Override
6547
public long capacity() {
@@ -75,7 +57,7 @@ public long position() {
7557
/** {@inheritDoc} */
7658
@Override
7759
public SingleBuffer position(long newPosition) {
78-
buffer.position(checkIndex(newPosition));
60+
buffer.position((int) newPosition);
7961
return this;
8062
}
8163

@@ -88,7 +70,7 @@ public long limit() {
8870
/** {@inheritDoc} */
8971
@Override
9072
public SingleBuffer limit(long newLimit) {
91-
buffer.limit(checkIndex(newLimit));
73+
buffer.limit((int) newLimit);
9274
return this;
9375
}
9476

@@ -108,7 +90,7 @@ public SingleBuffer get(byte[] dst) {
10890
/** {@inheritDoc} */
10991
@Override
11092
public byte get(long index) {
111-
return buffer.get(checkIndex(index));
93+
return buffer.get((int) index);
11294
}
11395

11496
/** {@inheritDoc} */

0 commit comments

Comments
 (0)