OpenSsl.memoryAddress(...) should use internalNioBuffer(...) if it can't access the memoryAddress (#10818)

Motivation:

We can make use of internalNioBuffer(...) if we cant access the memoryAddress. This at least will reduce the object creations.

Modifications:

Use internalNioBuffer(...) and so reduce the GC

Result:

Less object creation if we can't access the memory address.
This commit is contained in:
Norman Maurer 2020-11-25 10:31:58 +01:00
parent 7d53b97c0f
commit 6c446d14fd

View File

@ -525,7 +525,9 @@ public final class OpenSsl {
static long memoryAddress(ByteBuf buf) {
assert buf.isDirect();
return buf.hasMemoryAddress() ? buf.memoryAddress() : Buffer.address(buf.nioBuffer());
return buf.hasMemoryAddress() ? buf.memoryAddress() :
// Use internalNioBuffer to reduce object creation.
Buffer.address(buf.internalNioBuffer(0, buf.readableBytes()));
}
private OpenSsl() { }