Code simplification / optimization

This commit is contained in:
Trustin Lee 2009-06-15 08:05:27 +00:00
parent d76bfe72b5
commit f059f91ff4

View File

@ -356,18 +356,18 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
} }
private State readHeaders(ChannelBuffer buffer) throws TooLongFrameException { private State readHeaders(ChannelBuffer buffer) throws TooLongFrameException {
message.clearHeaders(); final HttpMessage message = this.message;
String line = readHeader(buffer); String line = readHeader(buffer);
String lastHeader = null; String lastHeader = null;
while (line.length() != 0) { if (line.length() != 0) {
char firstChar = line.charAt(0); message.clearHeaders();
switch (firstChar) { do {
switch (line.charAt(0)) {
case ' ': case '\t': case ' ': case '\t':
List<String> current = message.getHeaders(lastHeader); List<String> current = message.getHeaders(lastHeader);
int lastPos = current.size() - 1; int lastPos = current.size() - 1;
String newString = current.get(lastPos) + line.trim(); String newString = current.get(lastPos) + line.trim();
current.remove(lastPos); current.set(lastPos, newString);
current.add(newString);
break; break;
default: default:
String[] header = splitHeader(line); String[] header = splitHeader(line);
@ -375,6 +375,7 @@ public abstract class HttpMessageDecoder extends ReplayingDecoder<HttpMessageDec
lastHeader = header[0]; lastHeader = header[0];
} }
line = readHeader(buffer); line = readHeader(buffer);
} while (line.length() != 0);
} }
State nextState; State nextState;