From d4d01ba52c8c4c57f53386ae6e6505f91349772d Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Wed, 27 Feb 2013 14:31:29 -0800 Subject: [PATCH] Optimize SlicedByteBuf a little bit --- .../src/main/java/io/netty/buffer/SlicedByteBuf.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java b/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java index ef03fcd936..7af19a8e91 100644 --- a/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java +++ b/buffer/src/main/java/io/netty/buffer/SlicedByteBuf.java @@ -38,14 +38,8 @@ public class SlicedByteBuf extends AbstractDerivedByteBuf { public SlicedByteBuf(ByteBuf buffer, int index, int length) { super(length); - if (index < 0 || index > buffer.capacity()) { - throw new IndexOutOfBoundsException("Invalid index of " + index - + ", maximum is " + buffer.capacity()); - } - - if (index + length > buffer.capacity()) { - throw new IndexOutOfBoundsException("Invalid combined index of " - + (index + length) + ", maximum is " + buffer.capacity()); + if (index < 0 || index > buffer.capacity() - length) { + throw new IndexOutOfBoundsException(buffer.toString() + ".slice(" + index + ", " + length + ')'); } if (buffer instanceof SlicedByteBuf) {