[#2653] Remove uncessary range checks for performance reasons

Motivation:

I introduced range checks as part of 6c47cc9711 in some places. Unfortunally I also added some where these are not needed and so caused a performance regression.

Modification:

Remove range checks where not needed

Result:

Fixed performance regression.
This commit is contained in:
Norman Maurer 2014-07-14 11:40:27 +02:00
parent c75783abb5
commit 93c306602a

View File

@ -970,17 +970,17 @@ public abstract class AbstractByteBuf extends ByteBuf {
public int forEachByte(ByteBufProcessor processor) {
int index = readerIndex;
int length = writerIndex - index;
ensureAccessible();
return forEachByteAsc0(index, length, processor);
}
@Override
public int forEachByte(int index, int length, ByteBufProcessor processor) {
checkIndex(index, length);
return forEachByteAsc0(index, length, processor);
}
private int forEachByteAsc0(int index, int length, ByteBufProcessor processor) {
checkIndex(index, length);
if (processor == null) {
throw new NullPointerException("processor");
}
@ -1010,16 +1010,18 @@ public abstract class AbstractByteBuf extends ByteBuf {
public int forEachByteDesc(ByteBufProcessor processor) {
int index = readerIndex;
int length = writerIndex - index;
ensureAccessible();
return forEachByteDesc0(index, length, processor);
}
@Override
public int forEachByteDesc(int index, int length, ByteBufProcessor processor) {
checkIndex(index, length);
return forEachByteDesc0(index, length, processor);
}
private int forEachByteDesc0(int index, int length, ByteBufProcessor processor) {
checkIndex(index, length);
if (processor == null) {
throw new NullPointerException("processor");