Replace a variable with a constant wherever possible
This commit is contained in:
parent
1cb589a950
commit
4dce19b814
@ -243,7 +243,7 @@ public abstract class AbstractByteBuf implements ByteBuf {
|
|||||||
final int threshold = 1048576 * 4; // 4 MiB page
|
final int threshold = 1048576 * 4; // 4 MiB page
|
||||||
|
|
||||||
if (minNewCapacity == threshold) {
|
if (minNewCapacity == threshold) {
|
||||||
return minNewCapacity;
|
return threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If over threshold, do not double but just increase by threshold.
|
// If over threshold, do not double but just increase by threshold.
|
||||||
|
@ -1314,11 +1314,11 @@ public class HttpPostRequestDecoder {
|
|||||||
} else if (nextByte == HttpConstants.LF) {
|
} else if (nextByte == HttpConstants.LF) {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} else if (nextByte == '-') {
|
} else if (nextByte == '-') {
|
||||||
sb.append((char) nextByte);
|
sb.append('-');
|
||||||
// second check for closing delimiter
|
// second check for closing delimiter
|
||||||
nextByte = undecodedChunk.readByte();
|
nextByte = undecodedChunk.readByte();
|
||||||
if (nextByte == '-') {
|
if (nextByte == '-') {
|
||||||
sb.append((char) nextByte);
|
sb.append('-');
|
||||||
// now try to find if CRLF or LF there
|
// now try to find if CRLF or LF there
|
||||||
if (undecodedChunk.readable()) {
|
if (undecodedChunk.readable()) {
|
||||||
nextByte = undecodedChunk.readByte();
|
nextByte = undecodedChunk.readByte();
|
||||||
@ -1421,12 +1421,12 @@ public class HttpPostRequestDecoder {
|
|||||||
sao.setReadPosition(0);
|
sao.setReadPosition(0);
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} else if (nextByte == '-') {
|
} else if (nextByte == '-') {
|
||||||
sb.append((char) nextByte);
|
sb.append('-');
|
||||||
// second check for closing delimiter
|
// second check for closing delimiter
|
||||||
if (sao.pos < sao.limit) {
|
if (sao.pos < sao.limit) {
|
||||||
nextByte = sao.bytes[sao.pos++];
|
nextByte = sao.bytes[sao.pos++];
|
||||||
if (nextByte == '-') {
|
if (nextByte == '-') {
|
||||||
sb.append((char) nextByte);
|
sb.append('-');
|
||||||
// now try to find if CRLF or LF there
|
// now try to find if CRLF or LF there
|
||||||
if (sao.pos < sao.limit) {
|
if (sao.pos < sao.limit) {
|
||||||
nextByte = sao.bytes[sao.pos++];
|
nextByte = sao.bytes[sao.pos++];
|
||||||
|
@ -18,6 +18,8 @@ package io.netty.handler.codec.http.websocketx;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.netty.handler.codec.http.websocketx.WebSocketVersion.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instances the appropriate handshake class to use for clients
|
* Instances the appropriate handshake class to use for clients
|
||||||
*/
|
*/
|
||||||
@ -65,17 +67,17 @@ public class WebSocketClientHandshakerFactory {
|
|||||||
public WebSocketClientHandshaker newHandshaker(
|
public WebSocketClientHandshaker newHandshaker(
|
||||||
URI webSocketURL, WebSocketVersion version, String subprotocol,
|
URI webSocketURL, WebSocketVersion version, String subprotocol,
|
||||||
boolean allowExtensions, Map<String, String> customHeaders, int maxFramePayloadLength) {
|
boolean allowExtensions, Map<String, String> customHeaders, int maxFramePayloadLength) {
|
||||||
if (version == WebSocketVersion.V13) {
|
if (version == V13) {
|
||||||
return new WebSocketClientHandshaker13(
|
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(
|
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(
|
return new WebSocketClientHandshaker00(
|
||||||
webSocketURL, version, subprotocol, customHeaders, maxFramePayloadLength);
|
webSocketURL, V00, subprotocol, customHeaders, maxFramePayloadLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new WebSocketHandshakeException("Protocol version " + version.toString() + " not supported.");
|
throw new WebSocketHandshakeException("Protocol version " + version.toString() + " not supported.");
|
||||||
|
@ -253,7 +253,7 @@ final class InfBlocks {
|
|||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
bitb = b;
|
bitb = b;
|
||||||
bitk = k;
|
bitk = k;
|
||||||
z.avail_in = n;
|
z.avail_in = 0;
|
||||||
z.total_in += p - z.next_in_index;
|
z.total_in += p - z.next_in_index;
|
||||||
z.next_in_index = p;
|
z.next_in_index = p;
|
||||||
write = q;
|
write = q;
|
||||||
|
@ -342,8 +342,7 @@ public final class ChannelTaskScheduler {
|
|||||||
ScheduledFutureTask(EventExecutor executor, Runnable runnable, V result, long nanoTime, long period) {
|
ScheduledFutureTask(EventExecutor executor, Runnable runnable, V result, long nanoTime, long period) {
|
||||||
super(runnable, result);
|
super(runnable, result);
|
||||||
if (period == 0) {
|
if (period == 0) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException("period: 0 (expected: != 0)");
|
||||||
String.format("period: %d (expected: != 0)", period));
|
|
||||||
}
|
}
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
deadlineNanos = nanoTime;
|
deadlineNanos = nanoTime;
|
||||||
|
Loading…
Reference in New Issue
Block a user