Use AppendableCharSequence.charAtUnsafe(int)
in HttpObjectDecoder
(#9492)
Motivation: `HttpObjectDecoder` pre-checks that it doesn't request characters outside of the `AppendableCharSequence`'s length. `0` is always allowed because the minimal length of `AppendableCharSequence` is `1`. We can legally skip index check by using `AppendableCharSequence.charAtUnsafe(int)` in all existing cases in `HttpObjectDecoder`. Modifications: - Use `AppendableCharSequence.charAtUnsafe(int)` instead of `AppendableCharSequence.charAt(int)` in `HttpObjectDecoder`. Result: No unnecessary index checks in `HttpObjectDecoder`.
This commit is contained in:
parent
e6839aa228
commit
dd07caec6b
@ -571,7 +571,7 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder {
|
||||
}
|
||||
if (line.length() > 0) {
|
||||
do {
|
||||
char firstChar = line.charAt(0);
|
||||
char firstChar = line.charAtUnsafe(0);
|
||||
if (name != null && (firstChar == ' ' || firstChar == '\t')) {
|
||||
//please do not make one line from below code
|
||||
//as it breaks +XX:OptimizeStringConcat optimization
|
||||
@ -639,7 +639,7 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder {
|
||||
trailer = this.trailer = new DefaultLastHttpContent(Unpooled.EMPTY_BUFFER, validateHeaders);
|
||||
}
|
||||
while (line.length() > 0) {
|
||||
char firstChar = line.charAt(0);
|
||||
char firstChar = line.charAtUnsafe(0);
|
||||
if (lastHeader != null && (firstChar == ' ' || firstChar == '\t')) {
|
||||
List<String> current = trailer.trailingHeaders().getAll(lastHeader);
|
||||
if (!current.isEmpty()) {
|
||||
@ -723,14 +723,14 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder {
|
||||
|
||||
nameStart = findNonWhitespace(sb, 0);
|
||||
for (nameEnd = nameStart; nameEnd < length; nameEnd ++) {
|
||||
char ch = sb.charAt(nameEnd);
|
||||
char ch = sb.charAtUnsafe(nameEnd);
|
||||
if (ch == ':' || Character.isWhitespace(ch)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (colonEnd = nameEnd; colonEnd < length; colonEnd ++) {
|
||||
if (sb.charAt(colonEnd) == ':') {
|
||||
if (sb.charAtUnsafe(colonEnd) == ':') {
|
||||
colonEnd ++;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user