From 14fa1ef4b6ed24ffce49137493f9cdc9b8c7d172 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Sat, 27 Dec 2014 03:24:58 +0100 Subject: [PATCH] Remove unnecessary boxing and unboxing --- .../main/java/org/ethereum/net/message/ReasonCode.java | 2 +- .../main/java/org/ethereum/net/p2p/P2pMessageCodes.java | 2 +- ethereumj-core/src/main/java/org/ethereum/util/RLP.java | 4 ++-- .../src/test/java/test/ethereum/util/RLPTest.java | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/net/message/ReasonCode.java b/ethereumj-core/src/main/java/org/ethereum/net/message/ReasonCode.java index d38e183d..86d6b3c5 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/message/ReasonCode.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/message/ReasonCode.java @@ -74,7 +74,7 @@ public enum ReasonCode { } public static ReasonCode fromInt(int i) { - ReasonCode type = intToTypeMap.get(Integer.valueOf(i)); + ReasonCode type = intToTypeMap.get(i); if (type == null) return ReasonCode.UNKNOWN; return type; diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pMessageCodes.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pMessageCodes.java index 83ee8587..47fc3280 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pMessageCodes.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pMessageCodes.java @@ -79,7 +79,7 @@ public enum P2pMessageCodes { } public static P2pMessageCodes fromByte(byte i) { - P2pMessageCodes type = intToTypeMap.get(Integer.valueOf(i)); + P2pMessageCodes type = intToTypeMap.get((int) i); return type; } diff --git a/ethereumj-core/src/main/java/org/ethereum/util/RLP.java b/ethereumj-core/src/main/java/org/ethereum/util/RLP.java index d8fb7fa6..7443e074 100644 --- a/ethereumj-core/src/main/java/org/ethereum/util/RLP.java +++ b/ethereumj-core/src/main/java/org/ethereum/util/RLP.java @@ -420,7 +420,7 @@ public class RLP { while (pos < endPos) { if (level == levelToIndex) - index.add(new Integer(pos)); + index.add(pos); // It's a list with a payload more than 55 bytes // data[0] - 0xF7 = how many next bytes allocated @@ -925,7 +925,7 @@ public class RLP { return (inputLong == 0) ? ByteUtil.EMPTY_BYTE_ARRAY : asUnsignedByteArray(BigInteger.valueOf(inputLong)); } else if (input instanceof Integer) { Integer inputInt = (Integer) input; - return (inputInt == 0) ? ByteUtil.EMPTY_BYTE_ARRAY : asUnsignedByteArray(BigInteger.valueOf(inputInt.intValue())); + return (inputInt == 0) ? ByteUtil.EMPTY_BYTE_ARRAY : asUnsignedByteArray(BigInteger.valueOf(inputInt)); } else if (input instanceof BigInteger) { BigInteger inputBigInt = (BigInteger) input; return (inputBigInt == BigInteger.ZERO) ? ByteUtil.EMPTY_BYTE_ARRAY : asUnsignedByteArray(inputBigInt); diff --git a/ethereumj-core/src/test/java/test/ethereum/util/RLPTest.java b/ethereumj-core/src/test/java/test/ethereum/util/RLPTest.java index 42ba6157..8745a395 100644 --- a/ethereumj-core/src/test/java/test/ethereum/util/RLPTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/util/RLPTest.java @@ -614,7 +614,7 @@ public class RLPTest { @Test public void testEncodeZero() { - Integer test = new Integer(0); + Integer test = 0; String expected = "80"; byte[] encoderesult = RLP.encode(test); assertEquals(expected, Hex.toHexString(encoderesult)); @@ -625,7 +625,7 @@ public class RLPTest { @Test public void testEncodeSmallInteger() { - Integer test = new Integer(15); + Integer test = 15; String expected = "0f"; byte[] encoderesult = RLP.encode(test); assertEquals(expected, Hex.toHexString(encoderesult)); @@ -637,7 +637,7 @@ public class RLPTest { @Test public void testEncodeMediumInteger() { - Integer test = new Integer(1000); + Integer test = 1000; String expected = "8203e8"; byte[] encoderesult = RLP.encode(test); assertEquals(expected, Hex.toHexString(encoderesult)); @@ -646,7 +646,7 @@ public class RLPTest { int result = byteArrayToInt(decodeResult); assertEquals(test, Integer.valueOf(result)); - test = new Integer(1024); + test = 1024; expected = "820400"; encoderesult = RLP.encode(test); assertEquals(expected, Hex.toHexString(encoderesult));