Remove duplicated read byte array methods
This commit removes duplicated methods for reading byte arrays in StreamInput. One method would read a byte array by repeatedly calling StreamInput#readByte in a loop, and the other would just call StreamInput#readBytes. In this commit, we remove the former. Relates #19023
This commit is contained in:
parent
a379d62187
commit
6d04c1e78e
|
@ -439,7 +439,7 @@ public abstract class StreamInput extends InputStream {
|
|||
case 5:
|
||||
return readBoolean();
|
||||
case 6:
|
||||
return fastReadByteArray();
|
||||
return readByteArray();
|
||||
case 7:
|
||||
return readArrayList();
|
||||
case 8:
|
||||
|
@ -477,13 +477,6 @@ public abstract class StreamInput extends InputStream {
|
|||
}
|
||||
}
|
||||
|
||||
private byte[] fastReadByteArray() throws IOException {
|
||||
int bytesSize = readVInt();
|
||||
byte[] value = new byte[bytesSize];
|
||||
readBytes(value, 0, bytesSize);
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List readArrayList() throws IOException {
|
||||
int size = readVInt();
|
||||
|
@ -609,12 +602,10 @@ public abstract class StreamInput extends InputStream {
|
|||
}
|
||||
|
||||
public byte[] readByteArray() throws IOException {
|
||||
int length = readVInt();
|
||||
byte[] values = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
values[i] = readByte();
|
||||
}
|
||||
return values;
|
||||
final int length = readVInt();
|
||||
final byte[] bytes = new byte[length];
|
||||
readBytes(bytes, 0, bytes.length);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue