Skip to content

Commit c42ed9b

Browse files
committed
Reduce Integer boxing
1 parent b6f502a commit c42ed9b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main/java/com/github/shyiko/mysql/binlog/io/ByteArrayInputStream.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
public class ByteArrayInputStream extends InputStream {
2727

2828
private InputStream inputStream;
29-
private Integer peek;
30-
private Integer pos, markPosition;
29+
private int peek = -1;
30+
private int pos, markPosition;
3131
private int blockLength = -1;
3232
private int initialBlockLength = -1;
3333

@@ -194,7 +194,7 @@ public int available() throws IOException {
194194
}
195195

196196
public int peek() throws IOException {
197-
if (peek == null) {
197+
if (peek == -1) {
198198
peek = readWithinBlockBoundaries();
199199
}
200200
return peek;
@@ -203,11 +203,11 @@ public int peek() throws IOException {
203203
@Override
204204
public int read() throws IOException {
205205
int result;
206-
if (peek == null) {
206+
if (peek == -1) {
207207
result = readWithinBlockBoundaries();
208208
} else {
209209
result = peek;
210-
peek = null;
210+
peek = -1;
211211
}
212212
if (result == -1) {
213213
throw new EOFException(String.format("Failed to read next byte from position %d", this.pos));
@@ -236,8 +236,8 @@ public int read(byte[] b, int off, int len) throws IOException {
236236
return 0;
237237
}
238238

239-
if (peek != null) {
240-
b[off] = (byte)(int)peek;
239+
if (peek != -1) {
240+
b[off] = (byte) peek;
241241
off += 1;
242242
len -= 1;
243243
}
@@ -248,8 +248,8 @@ public int read(byte[] b, int off, int len) throws IOException {
248248
this.pos += read;
249249
}
250250

251-
if (peek != null) {
252-
peek = null;
251+
if (peek != -1) {
252+
peek = -1;
253253
read = read <= 0 ? 1 : read + 1;
254254
}
255255

0 commit comments

Comments
 (0)