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 committed by GitHub
parent 9cfe3bf5e3
commit 0c2b761cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -555,7 +555,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() { }