mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-10-18 08:02:56 -04:00
Improved networking performance and stability
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user