|
@@ -4,15 +4,22 @@ import java.nio.charset.StandardCharsets;
|
4
|
4
|
import java.util.Arrays;
|
5
|
5
|
|
6
|
6
|
public final class CompactBytesDataInput implements CompactDataInput, AutoCloseable {
|
|
7
|
+ private static final int P6 = 1 << 6;
|
7
|
8
|
private static final int P7 = 1 << 7;
|
|
9
|
+ private static final int P13 = 1 << 13;
|
8
|
10
|
private static final int P14 = 1 << 14;
|
|
11
|
+ private static final int P20 = 1 << 20;
|
9
|
12
|
private static final int P21 = 1 << 21;
|
|
13
|
+ private static final int P27 = 1 << 27;
|
10
|
14
|
private static final int P28 = 1 << 28;
|
|
15
|
+ private static final long P34 = 1L << 34;
|
11
|
16
|
private static final long P35 = 1L << 35;
|
|
17
|
+ private static final long P41 = 1L << 41;
|
12
|
18
|
private static final long P42 = 1L << 42;
|
|
19
|
+ private static final long P48 = 1L << 48;
|
13
|
20
|
private static final long P49 = 1L << 49;
|
|
21
|
+ private static final long P55 = 1L << 55;
|
14
|
22
|
private static final long P56 = 1L << 56;
|
15
|
|
-
|
16
|
23
|
private final byte[] data;
|
17
|
24
|
private int offset;
|
18
|
25
|
|
|
@@ -86,22 +93,22 @@ public final class CompactBytesDataInput implements CompactDataInput, AutoClosea
|
86
|
93
|
@Override
|
87
|
94
|
public int readVarInt() {
|
88
|
95
|
int value = this.readVarUInt();
|
89
|
|
- return Integer.compareUnsigned(value & 1, 0) == 0 ? value >>> 1 : -((value >>> 1) + 1);
|
|
96
|
+ return (value & 1) == 0 ? value >>> 1 : -((value >>> 1) + 1);
|
90
|
97
|
}
|
91
|
98
|
|
92
|
99
|
@Override
|
93
|
100
|
public int readVarUInt() {
|
94
|
101
|
int value = data[offset++] & 0xFF;
|
95
|
|
- if (Integer.compareUnsigned(value & CompactBytesDataInput.P7, 0) == 0)
|
|
102
|
+ if ((value & CompactBytesDataInput.P7) == 0)
|
96
|
103
|
return value;
|
97
|
104
|
value = value & CompactBytesDataInput.P7 - 1 | (data[offset++] & 0xFF) << 7;
|
98
|
|
- if (Integer.compareUnsigned(value & CompactBytesDataInput.P14, 0) == 0)
|
|
105
|
+ if ((value & CompactBytesDataInput.P14) == 0)
|
99
|
106
|
return value;
|
100
|
107
|
value = value & CompactBytesDataInput.P14 - 1 | (data[offset++] & 0xFF) << 14;
|
101
|
|
- if (Integer.compareUnsigned(value & CompactBytesDataInput.P21, 0) == 0)
|
|
108
|
+ if ((value & CompactBytesDataInput.P21) == 0)
|
102
|
109
|
return value;
|
103
|
110
|
value = value & CompactBytesDataInput.P21 - 1 | (data[offset++] & 0xFF) << 21;
|
104
|
|
- if (Integer.compareUnsigned(value & CompactBytesDataInput.P28, 0) == 0)
|
|
111
|
+ if ((value & CompactBytesDataInput.P28) == 0)
|
105
|
112
|
return value;
|
106
|
113
|
return value & CompactBytesDataInput.P28 - 1 | (data[offset++] & 0xFF) << 28;
|
107
|
114
|
}
|