[#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:
parent
c75783abb5
commit
93c306602a
@ -970,17 +970,17 @@ public abstract class AbstractByteBuf extends ByteBuf {
|
|||||||
public int forEachByte(ByteBufProcessor processor) {
|
public int forEachByte(ByteBufProcessor processor) {
|
||||||
int index = readerIndex;
|
int index = readerIndex;
|
||||||
int length = writerIndex - index;
|
int length = writerIndex - index;
|
||||||
|
ensureAccessible();
|
||||||
return forEachByteAsc0(index, length, processor);
|
return forEachByteAsc0(index, length, processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int forEachByte(int index, int length, ByteBufProcessor processor) {
|
public int forEachByte(int index, int length, ByteBufProcessor processor) {
|
||||||
|
checkIndex(index, length);
|
||||||
return forEachByteAsc0(index, length, processor);
|
return forEachByteAsc0(index, length, processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int forEachByteAsc0(int index, int length, ByteBufProcessor processor) {
|
private int forEachByteAsc0(int index, int length, ByteBufProcessor processor) {
|
||||||
checkIndex(index, length);
|
|
||||||
|
|
||||||
if (processor == null) {
|
if (processor == null) {
|
||||||
throw new NullPointerException("processor");
|
throw new NullPointerException("processor");
|
||||||
}
|
}
|
||||||
@ -1010,16 +1010,18 @@ public abstract class AbstractByteBuf extends ByteBuf {
|
|||||||
public int forEachByteDesc(ByteBufProcessor processor) {
|
public int forEachByteDesc(ByteBufProcessor processor) {
|
||||||
int index = readerIndex;
|
int index = readerIndex;
|
||||||
int length = writerIndex - index;
|
int length = writerIndex - index;
|
||||||
|
ensureAccessible();
|
||||||
return forEachByteDesc0(index, length, processor);
|
return forEachByteDesc0(index, length, processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int forEachByteDesc(int index, int length, ByteBufProcessor processor) {
|
public int forEachByteDesc(int index, int length, ByteBufProcessor processor) {
|
||||||
|
checkIndex(index, length);
|
||||||
|
|
||||||
return forEachByteDesc0(index, length, processor);
|
return forEachByteDesc0(index, length, processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int forEachByteDesc0(int index, int length, ByteBufProcessor processor) {
|
private int forEachByteDesc0(int index, int length, ByteBufProcessor processor) {
|
||||||
checkIndex(index, length);
|
|
||||||
|
|
||||||
if (processor == null) {
|
if (processor == null) {
|
||||||
throw new NullPointerException("processor");
|
throw new NullPointerException("processor");
|
||||||
|
Loading…
Reference in New Issue
Block a user