From effac4fd0dcb66ee261be103130507296830b43f Mon Sep 17 00:00:00 2001 From: takezoe Date: Sun, 8 Dec 2024 11:16:18 +0900 Subject: [PATCH] Remove unreachable code in OrderedPeriodParser --- .../java/io/trino/util/DateTimeUtils.java | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java b/core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java index b364630f4a4e..e1ac2dd1e266 100644 --- a/core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java +++ b/core/trino-main/src/main/java/io/trino/util/DateTimeUtils.java @@ -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); @@ -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; } } }