Improved networking performance and stability

This commit is contained in:
Obique PSWG
2016-01-31 15:35:38 -06:00
parent 731311ed2d
commit 925791f594
6 changed files with 254 additions and 126 deletions
+6 -7
View File
@@ -9,13 +9,12 @@ public class Compression {
private static final LZ4Compressor COMPRESSOR = LZ4Factory.safeInstance().highCompressor();
private static final LZ4SafeDecompressor DECOMPRESSOR = LZ4Factory.safeInstance().safeDecompressor();
public static byte [] compress(byte [] data) {
int maxCompressedLength = COMPRESSOR.maxCompressedLength(data.length);
byte[] compressed = new byte[maxCompressedLength];
int length = COMPRESSOR.compress(data, compressed);
byte [] ret = new byte[length];
System.arraycopy(compressed, 0, ret, 0, length);
return ret;
public static int getMaxCompressedLength(int len) {
return COMPRESSOR.maxCompressedLength(len);
}
public static int compress(byte [] data, byte [] buffer) {
return COMPRESSOR.compress(data, buffer);
}
public static byte [] decompress(byte [] data) {