mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-23 00:40:51 +01:00
why much code if less do trick
This commit is contained in:
parent
7862828633
commit
750fff662f
@ -18,13 +18,8 @@ public class PayloadBuffer {
|
||||
}
|
||||
public HPacket[] receive() {
|
||||
if (buffer.length < 6) return new HPacket[0];
|
||||
|
||||
HPacket total = new HPacket(buffer);
|
||||
if (total.getBytesLength() - 4 == total.length()) {
|
||||
buffer = new byte[0];
|
||||
return new HPacket[]{total};
|
||||
}
|
||||
else if (total.getBytesLength() - 4 > total.length()) {
|
||||
|
||||
ArrayList<HPacket> all = new ArrayList<>();
|
||||
while (total.getBytesLength() >= 4 && total.getBytesLength() - 4 >= total.length()){
|
||||
all.add(new HPacket(Arrays.copyOfRange(buffer, 0, total.length() + 4)));
|
||||
@ -33,10 +28,6 @@ public class PayloadBuffer {
|
||||
}
|
||||
return all.toArray(new HPacket[all.size()]);
|
||||
}
|
||||
else {
|
||||
return new HPacket[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private byte[] combineByteArrays(byte[] arr1, byte[] arr2) {
|
||||
|
Loading…
Reference in New Issue
Block a user