Skip to content

Commit 41bae0a

Browse files
committed
Change different occurences of chunk sizes to MultiBuffer.DEFAULT_CHUNK_SIZE
1 parent 0ff4987 commit 41bae0a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final class BufferHolder {
2020
long size = channel.size();
2121
if (mode == FileMode.MEMORY) {
2222
Buffer buf;
23-
if (size <= Integer.MAX_VALUE) {
23+
if (size <= MultiBuffer.DEFAULT_CHUNK_SIZE) {
2424
buf = new SingleBuffer(size);
2525
} else {
2626
buf = new MultiBuffer(size);
@@ -32,7 +32,7 @@ final class BufferHolder {
3232
}
3333
this.buffer = buf;
3434
} else {
35-
if (size <= Integer.MAX_VALUE) {
35+
if (size <= MultiBuffer.DEFAULT_CHUNK_SIZE) {
3636
this.buffer = SingleBuffer.mapFromChannel(channel);
3737
} else {
3838
this.buffer = MultiBuffer.mapFromChannel(channel);
@@ -52,10 +52,9 @@ final class BufferHolder {
5252
if (null == stream) {
5353
throw new NullPointerException("Unable to use a NULL InputStream");
5454
}
55-
final int chunkSize = Integer.MAX_VALUE / 2;
5655
List<ByteBuffer> chunks = new ArrayList<>();
5756
long total = 0;
58-
byte[] tmp = new byte[chunkSize];
57+
byte[] tmp = new byte[MultiBuffer.DEFAULT_CHUNK_SIZE];
5958
int read;
6059

6160
while (-1 != (read = stream.read(tmp))) {
@@ -66,7 +65,7 @@ final class BufferHolder {
6665
total += read;
6766
}
6867

69-
if (total <= chunkSize) {
68+
if (total <= MultiBuffer.DEFAULT_CHUNK_SIZE) {
7069
byte[] data = new byte[(int) total];
7170
int pos = 0;
7271
for (ByteBuffer chunk : chunks) {

0 commit comments

Comments
 (0)