Skip to content

Commit

Permalink
minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Aug 27, 2024
1 parent 8791118 commit eeb9bb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main/java/com/esaulpaugh/headlong/abi/TypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ static StringBuilder newTypeBuilder() {

private static TupleType<?> parseTupleType(final String rawTypeStr, final String[] elementNames, final int flags) { /* assumes that rawTypeStr.charAt(0) == '(' */
final int len = rawTypeStr.length();
if (len == 2 && rawTypeStr.equals("()")) return TupleType.empty(flags);
if (len == 2 && "()".equals(rawTypeStr)) return TupleType.empty(flags);
final List<ABIType<?>> elements = new ArrayList<>(8);
int argEnd = 1;
final StringBuilder canonicalType = newTypeBuilder();
Expand Down Expand Up @@ -263,17 +263,18 @@ private static TupleType<?> parseTupleType(final String rawTypeStr, final String
}

private static int nextTerminator(String signature, int i) {
do {
switch (signature.charAt(++i)) {
for ( ; ; i++) {
switch (signature.charAt(i)) {
case ',':
case ')': return i;
}
} while (true);
}
}

private static int findSubtupleEnd(String parentTypeString, int i) {
for (int depth = 0; ; i++) {
switch (parentTypeString.charAt(i)) {
int depth = 0;
do {
switch (parentTypeString.charAt(i++)) {
case '(':
depth++;
continue;
Expand All @@ -283,6 +284,6 @@ private static int findSubtupleEnd(String parentTypeString, int i) {
}
depth--;
}
}
} while (true);
}
}
1 change: 1 addition & 0 deletions src/main/java/com/esaulpaugh/headlong/rlp/RLPList.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public Iterator<RLPItem> iterator(RLPDecoder decoder) {
return new Iterator<RLPItem>() {

int idx = dataIndex;

@Override
public boolean hasNext() {
return idx < endIndex;
Expand Down

0 comments on commit eeb9bb0

Please sign in to comment.