From 7922757575b942d5de5f38d3566857f70b9b4ce6 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 7 Jun 2017 10:33:54 +0200 Subject: [PATCH] Allow to access memoryAddress of wrapped ByteBuf for ReadOnlyByteBuf Motivation: We should allow to access the memoryAddress of the wrapped ByteBuf when using ReadOnlyByteBuf for peformance reasons. If a user act on a memoryAddress its his responsible anyway to do nothing "stupid". Modifications: Delegate to wrapped ByteBuf. Result: Less performance overhead for various operations and also when writing to a native transport (which needs the memoryAddress). --- buffer/src/main/java/io/netty/buffer/ReadOnlyByteBuf.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buffer/src/main/java/io/netty/buffer/ReadOnlyByteBuf.java b/buffer/src/main/java/io/netty/buffer/ReadOnlyByteBuf.java index 52d6f8c40c..cbc1d24f75 100644 --- a/buffer/src/main/java/io/netty/buffer/ReadOnlyByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/ReadOnlyByteBuf.java @@ -103,12 +103,12 @@ public class ReadOnlyByteBuf extends AbstractDerivedByteBuf { @Override public boolean hasMemoryAddress() { - return false; + return unwrap().hasMemoryAddress(); } @Override public long memoryAddress() { - throw new ReadOnlyBufferException(); + return unwrap().memoryAddress(); } @Override