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:
parent
9cfe3bf5e3
commit
0c2b761cfb
@ -555,7 +555,9 @@ public final class OpenSsl {
|
|||||||
|
|
||||||
static long memoryAddress(ByteBuf buf) {
|
static long memoryAddress(ByteBuf buf) {
|
||||||
assert buf.isDirect();
|
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() { }
|
private OpenSsl() { }
|
||||||
|
Loading…
Reference in New Issue
Block a user