13
0
geforkt von Mirrors/Velocity

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
public ByteBuf process(ChannelHandlerContext ctx, ByteBuf source) throws ShortBufferException {
ByteBuf out = ctx.alloc().directBuffer(source.readableBytes());
try {
process(source, out);
return out;
} catch (Exception e) {
out.release();
throw e;
}
ensureNotDisposed();
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;
}
@Override