Skip to content

Commit

Permalink
Change up syntax to see if impossible `ArrayIndexOutOfBoundsException…
Browse files Browse the repository at this point in the history
…` goes away.

PiperOrigin-RevId: 354582499
  • Loading branch information
justinhorvitz authored and copybara-github committed Jan 29, 2021
1 parent 9a0bcbb commit 9c5124f
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -733,15 +733,13 @@ private int walk(
private static <E> int replay(
ImmutableList.Builder<E> output, Object[] children, byte[] memo, int pos) {
for (Object child : children) {
if ((memo[pos >> 3] & (1 << (pos & 7))) != 0) {
if (child instanceof Object[]) {
pos = replay(output, (Object[]) child, memo, pos + 1);
} else {
output.add((E) child);
++pos;
}
if ((memo[pos >> 3] & (1 << (pos & 7))) == 0) {
pos++;
} else if (child instanceof Object[]) {
pos = replay(output, (Object[]) child, memo, pos + 1);
} else {
++pos;
output.add((E) child);
pos++;
}
}
return pos;
Expand Down

0 comments on commit 9c5124f

Please sign in to comment.