Replace a variable with a constant wherever possible

This commit is contained in:
Trustin Lee 2012-11-12 09:43:14 +09:00
parent 1cb589a950
commit 4dce19b814
5 changed files with 15 additions and 14 deletions

View File

@ -243,7 +243,7 @@ public abstract class AbstractByteBuf implements ByteBuf {
final int threshold = 1048576 * 4; // 4 MiB page
if (minNewCapacity == threshold) {
return minNewCapacity;
return threshold;
}
// If over threshold, do not double but just increase by threshold.

View File

@ -1314,11 +1314,11 @@ public class HttpPostRequestDecoder {
} else if (nextByte == HttpConstants.LF) {
return sb.toString();
} else if (nextByte == '-') {
sb.append((char) nextByte);
sb.append('-');
// second check for closing delimiter
nextByte = undecodedChunk.readByte();
if (nextByte == '-') {
sb.append((char) nextByte);
sb.append('-');
// now try to find if CRLF or LF there
if (undecodedChunk.readable()) {
nextByte = undecodedChunk.readByte();
@ -1421,12 +1421,12 @@ public class HttpPostRequestDecoder {
sao.setReadPosition(0);
return sb.toString();
} else if (nextByte == '-') {
sb.append((char) nextByte);
sb.append('-');
// second check for closing delimiter
if (sao.pos < sao.limit) {
nextByte = sao.bytes[sao.pos++];
if (nextByte == '-') {
sb.append((char) nextByte);
sb.append('-');
// now try to find if CRLF or LF there
if (sao.pos < sao.limit) {
nextByte = sao.bytes[sao.pos++];

View File

@ -18,6 +18,8 @@ package io.netty.handler.codec.http.websocketx;
import java.net.URI;
import java.util.Map;
import static io.netty.handler.codec.http.websocketx.WebSocketVersion.*;
/**
* Instances the appropriate handshake class to use for clients
*/
@ -65,17 +67,17 @@ public class WebSocketClientHandshakerFactory {
public WebSocketClientHandshaker newHandshaker(
URI webSocketURL, WebSocketVersion version, String subprotocol,
boolean allowExtensions, Map<String, String> customHeaders, int maxFramePayloadLength) {
if (version == WebSocketVersion.V13) {
if (version == V13) {
return new WebSocketClientHandshaker13(
webSocketURL, version, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength);
webSocketURL, V13, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength);
}
if (version == WebSocketVersion.V08) {
if (version == V08) {
return new WebSocketClientHandshaker08(
webSocketURL, version, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength);
webSocketURL, V08, subprotocol, allowExtensions, customHeaders, maxFramePayloadLength);
}
if (version == WebSocketVersion.V00) {
if (version == V00) {
return new WebSocketClientHandshaker00(
webSocketURL, version, subprotocol, customHeaders, maxFramePayloadLength);
webSocketURL, V00, subprotocol, customHeaders, maxFramePayloadLength);
}
throw new WebSocketHandshakeException("Protocol version " + version.toString() + " not supported.");

View File

@ -253,7 +253,7 @@ final class InfBlocks {
if (n == 0) {
bitb = b;
bitk = k;
z.avail_in = n;
z.avail_in = 0;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
write = q;

View File

@ -342,8 +342,7 @@ public final class ChannelTaskScheduler {
ScheduledFutureTask(EventExecutor executor, Runnable runnable, V result, long nanoTime, long period) {
super(runnable, result);
if (period == 0) {
throw new IllegalArgumentException(
String.format("period: %d (expected: != 0)", period));
throw new IllegalArgumentException("period: 0 (expected: != 0)");
}
this.executor = executor;
deadlineNanos = nanoTime;