Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Mar 6, 2021
1 parent 8f7139f commit 781e175
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/main/java/com/esaulpaugh/headlong/util/SuperSerial.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private static Object serializeArray(ArrayType<? extends ABIType<?>, ?> type, Ob
case TYPE_CODE_BIG_INTEGER:
case TYPE_CODE_BIG_DECIMAL:
case TYPE_CODE_ARRAY:
case TYPE_CODE_TUPLE: return serializeObjectArray(arr, type.getElementType());
case TYPE_CODE_TUPLE: return serializeObjectArray((Object[]) arr, type.getElementType());
default: throw new Error();
}
}
Expand All @@ -241,9 +241,8 @@ private static Object deserializeArray(ArrayType<? extends ABIType<?>,?> type, R
}

private static byte[][] serializeBooleanArray(boolean[] booleans) {
final int len = booleans.length;
byte[][] out = new byte[len][];
for (int i = 0; i < len; i++) {
byte[][] out = new byte[booleans.length][];
for (int i = 0; i < booleans.length; i++) {
out[i] = serializeBoolean(booleans[i]);
}
return out;
Expand All @@ -268,9 +267,8 @@ private static Object deserializeByteArray(RLPItem item, boolean isString) {
}

private static byte[][] serializeIntArray(int[] ints) {
final int len = ints.length;
byte[][] out = new byte[len][];
for (int i = 0; i < len; i++) {
byte[][] out = new byte[ints.length][];
for (int i = 0; i < ints.length; i++) {
out[i] = Integers.toBytes(ints[i]);
}
return out;
Expand All @@ -289,9 +287,8 @@ private static int[] deserializeIntArray(RLPList list, IntType type) {
}

private static byte[][] serializeLongArray(long[] longs) {
final int len = longs.length;
byte[][] out = new byte[len][];
for (int i = 0; i < len; i++) {
byte[][] out = new byte[longs.length][];
for (int i = 0; i < longs.length; i++) {
out[i] = Integers.toBytes(longs[i]);
}
return out;
Expand All @@ -309,11 +306,9 @@ private static long[] deserializeLongArray(RLPList list, LongType type) {
return in;
}

private static Object[] serializeObjectArray(Object arr, ABIType<?> elementType) {
Object[] objects = (Object[]) arr;
final int len = objects.length;
Object[] out = new Object[len];
for (int i = 0; i < len; i++) {
private static Object[] serializeObjectArray(Object[] objects, ABIType<?> elementType) {
Object[] out = new Object[objects.length];
for (int i = 0; i < objects.length; i++) {
out[i] = serialize(elementType, objects[i]);
}
return out;
Expand Down

0 comments on commit 781e175

Please sign in to comment.