3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-09-29 06:30:16 +02:00

Small optimization for NativeVelocityCipher

Instead of going through the general process function, which does extra
checks to ensure that its arguments are sane, move "closer" to the action
by stripping down to the actual implementation.
Dieser Commit ist enthalten in:
Andrew Steinborn 2019-05-21 00:56:14 -04:00
Ursprung b09331b79b
Commit 821a7a45bc

Datei anzeigen

@ -50,14 +50,16 @@ public class NativeVelocityCipher implements VelocityCipher {
@Override @Override
public ByteBuf process(ChannelHandlerContext ctx, ByteBuf source) throws ShortBufferException { public ByteBuf process(ChannelHandlerContext ctx, ByteBuf source) throws ShortBufferException {
ByteBuf out = ctx.alloc().directBuffer(source.readableBytes()); ensureNotDisposed();
try {
process(source, out); int len = source.readableBytes();
ByteBuf out = ctx.alloc().directBuffer(len);
impl.process(this.ctx, source.memoryAddress() + source.readerIndex(), len,
out.memoryAddress(), encrypt);
source.skipBytes(len);
out.writerIndex(len);
return out; return out;
} catch (Exception e) {
out.release();
throw e;
}
} }
@Override @Override