Improve Performance by calling very much less sao.setReadPosition(x)
This commit is contained in:
parent
b0ba1b9bb6
commit
25c31cd137
@ -1395,6 +1395,7 @@ public class HttpPostRequestDecoder {
|
||||
boolean newLine = true;
|
||||
int index = 0;
|
||||
int lastPosition = undecodedChunk.readerIndex();
|
||||
int setReadPosition = -1;
|
||||
boolean found = false;
|
||||
|
||||
while (sao.pos < sao.limit) {
|
||||
@ -1419,23 +1420,23 @@ public class HttpPostRequestDecoder {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
setReadPosition = sao.pos;
|
||||
lastPosition = sao.pos - 2;
|
||||
}
|
||||
} else {
|
||||
// save last valid position
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
setReadPosition = sao.pos;
|
||||
lastPosition = sao.pos;
|
||||
}
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
setReadPosition = sao.pos;
|
||||
lastPosition = sao.pos - 1;
|
||||
} else {
|
||||
// save last valid position
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
setReadPosition = sao.pos;
|
||||
lastPosition = sao.pos;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1446,26 +1447,30 @@ public class HttpPostRequestDecoder {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
setReadPosition = sao.pos;
|
||||
lastPosition = sao.pos - 2;
|
||||
}
|
||||
} else {
|
||||
// save last valid position
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
setReadPosition = sao.pos;
|
||||
lastPosition = sao.pos;
|
||||
}
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
setReadPosition = sao.pos;
|
||||
lastPosition = sao.pos - 1;
|
||||
} else {
|
||||
// save last valid position
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
setReadPosition = sao.pos;
|
||||
lastPosition = sao.pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (setReadPosition > 0) {
|
||||
sao.pos = setReadPosition;
|
||||
sao.setReadPosition(0);
|
||||
}
|
||||
ChannelBuffer buffer = undecodedChunk.slice(readerIndex, lastPosition - readerIndex);
|
||||
if (found) {
|
||||
// found so lastPosition is correct and final
|
||||
@ -1604,6 +1609,7 @@ public class HttpPostRequestDecoder {
|
||||
boolean newLine = true;
|
||||
int index = 0;
|
||||
int lastPosition = undecodedChunk.readerIndex();
|
||||
int setReadPosition = -1;
|
||||
boolean found = false;
|
||||
|
||||
while (sao.pos < sao.limit) {
|
||||
@ -1628,21 +1634,21 @@ public class HttpPostRequestDecoder {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
lastPosition = sao.pos - 2;
|
||||
setReadPosition = sao.pos;
|
||||
}
|
||||
} else {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
lastPosition = sao.pos;
|
||||
setReadPosition = sao.pos;
|
||||
}
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
lastPosition = sao.pos - 1;
|
||||
setReadPosition = sao.pos;
|
||||
} else {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
lastPosition = sao.pos;
|
||||
setReadPosition = sao.pos;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1653,24 +1659,28 @@ public class HttpPostRequestDecoder {
|
||||
if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex() - 2;
|
||||
lastPosition = sao.pos - 2;
|
||||
setReadPosition = sao.pos;
|
||||
}
|
||||
} else {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
lastPosition = sao.pos;
|
||||
setReadPosition = sao.pos;
|
||||
}
|
||||
} else if (nextByte == HttpConstants.LF) {
|
||||
newLine = true;
|
||||
index = 0;
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex() - 1;
|
||||
lastPosition = sao.pos - 1;
|
||||
setReadPosition = sao.pos;
|
||||
} else {
|
||||
sao.setReadPosition(0);
|
||||
lastPosition = undecodedChunk.readerIndex();
|
||||
lastPosition = sao.pos;
|
||||
setReadPosition = sao.pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (setReadPosition > 0) {
|
||||
sao.pos = setReadPosition;
|
||||
sao.setReadPosition(0);
|
||||
}
|
||||
if (found) {
|
||||
// found so lastPosition is correct
|
||||
// but position is just after the delimiter (either close delimiter or simple one)
|
||||
|
Loading…
x
Reference in New Issue
Block a user