Skip to content

Commit 751ed6c

Browse files
windienormanmaurer
authored andcommitted
Avoid unnecessary boxing/unboxing
Motivation: Boxing/unboxing can be avoided. Modifications: Use parseInt/parseLong to avoid unnecessary boxing/unboxing. Result: Remove unnecessary boxing/unboxing.
1 parent b4be040 commit 751ed6c

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

codec-http/src/main/java/io/netty/handler/codec/http/cookie/ClientCookieDecoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private void parse6(int nameStart, int valueStart, int valueEnd) {
233233

234234
private void setMaxAge(String value) {
235235
try {
236-
maxAge = Math.max(Long.valueOf(value), 0L);
236+
maxAge = Math.max(Long.parseLong(value), 0L);
237237
} catch (NumberFormatException e1) {
238238
// ignore failure to parse -> treat as session cookie
239239
}

example/src/main/java/io/netty/example/http2/Http2ExampleUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private Http2ExampleUtil() { }
4747
*/
4848
public static int toInt(String string, int defaultValue) {
4949
if (string != null && !string.isEmpty()) {
50-
return Integer.valueOf(string);
50+
return Integer.parseInt(string);
5151
}
5252
return defaultValue;
5353
}

example/src/main/java/io/netty/example/http2/tiles/Http2RequestHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
2525
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
2626
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
27-
import static java.lang.Integer.valueOf;
27+
import static java.lang.Integer.parseInt;
2828
import io.netty.buffer.ByteBuf;
2929
import io.netty.channel.ChannelHandlerContext;
3030
import io.netty.channel.SimpleChannelInboundHandler;
@@ -77,7 +77,7 @@ private void sendBadRequest(ChannelHandlerContext ctx, String streamId) {
7777

7878
private void handleImage(String x, String y, ChannelHandlerContext ctx, String streamId, int latency,
7979
FullHttpRequest request) {
80-
ByteBuf image = ImageCache.INSTANCE.image(valueOf(x), valueOf(y));
80+
ByteBuf image = ImageCache.INSTANCE.image(parseInt(x), parseInt(y));
8181
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK, image.duplicate());
8282
response.headers().set(CONTENT_TYPE, "image/jpeg");
8383
sendResponse(ctx, streamId, latency, response, request);

transport/src/main/java/io/netty/channel/pool/SimpleChannelPool.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private void notifyHealthCheck(Future<Boolean> future, Channel ch, Promise<Chann
184184
assert ch.eventLoop().inEventLoop();
185185

186186
if (future.isSuccess()) {
187-
if (future.getNow() == Boolean.TRUE) {
187+
if (future.getNow()) {
188188
try {
189189
ch.attr(POOL_KEY).set(this);
190190
handler.channelAcquired(ch);

0 commit comments

Comments
 (0)