Optimize SlicedByteBuf a little bit
This commit is contained in:
parent
cb202da832
commit
d4d01ba52c
@ -38,14 +38,8 @@ public class SlicedByteBuf extends AbstractDerivedByteBuf {
|
|||||||
|
|
||||||
public SlicedByteBuf(ByteBuf buffer, int index, int length) {
|
public SlicedByteBuf(ByteBuf buffer, int index, int length) {
|
||||||
super(length);
|
super(length);
|
||||||
if (index < 0 || index > buffer.capacity()) {
|
if (index < 0 || index > buffer.capacity() - length) {
|
||||||
throw new IndexOutOfBoundsException("Invalid index of " + index
|
throw new IndexOutOfBoundsException(buffer.toString() + ".slice(" + index + ", " + length + ')');
|
||||||
+ ", maximum is " + buffer.capacity());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index + length > buffer.capacity()) {
|
|
||||||
throw new IndexOutOfBoundsException("Invalid combined index of "
|
|
||||||
+ (index + length) + ", maximum is " + buffer.capacity());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer instanceof SlicedByteBuf) {
|
if (buffer instanceof SlicedByteBuf) {
|
||||||
|
Loading…
Reference in New Issue
Block a user