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.
This commit is contained in:
Andrew Steinborn
2019-05-21 00:56:14 -04:00
parent b09331b79b
commit 821a7a45bc

View File

@@ -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();
return out; ByteBuf out = ctx.alloc().directBuffer(len);
} catch (Exception e) {
out.release(); impl.process(this.ctx, source.memoryAddress() + source.readerIndex(), len,
throw e; out.memoryAddress(), encrypt);
} source.skipBytes(len);
out.writerIndex(len);
return out;
} }
@Override @Override