Remove unnecessary boxing and unboxing

This commit is contained in:
Chris Beams 2014-12-27 03:24:58 +01:00
parent 6c4502150e
commit 14fa1ef4b6
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73
4 changed files with 8 additions and 8 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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));