[#1553] Improve performance of encodeInitialLine

This commit is contained in:
alain 2013-07-09 18:37:36 -07:00 committed by Norman Maurer
parent 40bbe2130a
commit 2adf393277
2 changed files with 4 additions and 4 deletions

View File

@ -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));
}

View File

@ -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);
}
}