Start optimizing server list ping.
This commit is contained in:
@@ -63,6 +63,23 @@ public class LibdeflateVelocityCompressor implements VelocityCompressor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deflateSingle(ByteBuf source, ByteBuf destination) throws DataFormatException {
|
||||
ensureNotDisposed();
|
||||
|
||||
long sourceAddress = source.memoryAddress() + source.readerIndex();
|
||||
long destinationAddress = destination.memoryAddress() + destination.writerIndex();
|
||||
|
||||
int produced = deflate.process(deflateCtx, sourceAddress, source.readableBytes(),
|
||||
destinationAddress, destination.writableBytes());
|
||||
if (produced > 0) {
|
||||
destination.writerIndex(destination.writerIndex() + produced);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ensureNotDisposed() {
|
||||
Preconditions.checkState(!disposed, "Object already disposed");
|
||||
}
|
||||
|
@@ -14,4 +14,9 @@ public interface VelocityCompressor extends Disposable, Native {
|
||||
throws DataFormatException;
|
||||
|
||||
void deflate(ByteBuf source, ByteBuf destination) throws DataFormatException;
|
||||
|
||||
default boolean deflateSingle(ByteBuf source, ByteBuf destination) throws DataFormatException {
|
||||
deflate(source, destination);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user