Optimize SlicedByteBuf a little bit

This commit is contained in:
Trustin Lee 2013-02-27 14:31:29 -08:00
parent cb202da832
commit d4d01ba52c

View File

@ -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) {