Skip to content

Commit

Permalink
Remove unreachable code in OrderedPeriodParser
Browse files Browse the repository at this point in the history
  • Loading branch information
takezoe authored and dain committed Dec 30, 2024
1 parent e8cc8e3 commit effac4f
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,6 @@ public int parseInto(ReadWritablePeriod period, String text, int position, Local
int bestValidPos = position;
ReadWritablePeriod bestValidPeriod = null;

int bestInvalidPos = position;

for (PeriodParser parser : parsers) {
ReadWritablePeriod parsedPeriod = new MutablePeriod();
int parsePos = parser.parseInto(parsedPeriod, text, position, locale);
Expand All @@ -422,23 +420,13 @@ public int parseInto(ReadWritablePeriod period, String text, int position, Local
}
}
}
else if (parsePos < 0) {
parsePos = ~parsePos;
if (parsePos > bestInvalidPos) {
bestInvalidPos = parsePos;
}
}
}

if (bestValidPos > position || (bestValidPos == position)) {
// Restore the state to the best valid parse.
if (bestValidPeriod != null) {
period.setPeriod(bestValidPeriod);
}
return bestValidPos;
// Restore the state to the best valid parse.
if (bestValidPeriod != null) {
period.setPeriod(bestValidPeriod);
}

return ~bestInvalidPos;
return bestValidPos;
}
}
}

0 comments on commit effac4f

Please sign in to comment.