[#1553] Improve performance of encodeInitialLine
This commit is contained in:
parent
40bbe2130a
commit
2adf393277
@ -130,7 +130,7 @@ public abstract class HttpObjectEncoder<H extends HttpMessage> extends MessageTo
|
||||
buf.writeBytes(CRLF);
|
||||
}
|
||||
|
||||
private static void encodeAscii(String s, ByteBuf buf) {
|
||||
protected static void encodeAscii(String s, ByteBuf buf) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
buf.writeByte(s.charAt(i));
|
||||
}
|
||||
|
@ -34,11 +34,11 @@ public class HttpResponseEncoder extends HttpObjectEncoder<HttpResponse> {
|
||||
|
||||
@Override
|
||||
protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception {
|
||||
buf.writeBytes(response.getProtocolVersion().toString().getBytes(CharsetUtil.US_ASCII));
|
||||
encodeAscii(response.getProtocolVersion().toString(), buf);
|
||||
buf.writeByte(SP);
|
||||
buf.writeBytes(String.valueOf(response.getStatus().code()).getBytes(CharsetUtil.US_ASCII));
|
||||
encodeAscii(String.valueOf(response.getStatus().code()), buf);
|
||||
buf.writeByte(SP);
|
||||
buf.writeBytes(String.valueOf(response.getStatus().reasonPhrase()).getBytes(CharsetUtil.US_ASCII));
|
||||
encodeAscii(String.valueOf(response.getStatus().reasonPhrase()), buf);
|
||||
buf.writeBytes(CRLF);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user