<i18n dev> RFR: 8349000: Performance improvement for Currency.isPastCutoverDate(String) [v2]
Andrey Turbanov
aturbanov at openjdk.org
Mon Feb 3 12:49:51 UTC 2025
On Fri, 31 Jan 2025 19:46:37 GMT, Justin Lu <jlu at openjdk.org> wrote:
>> Please review this PR which improves the performance of cut-over date checking when the user supplies a properties override via the `java.util.currency.data` sys prop. Replacing the `SimpleDateFormat` with a _java.time_ alternative has better performance. It should be noted that this method is only entered when the string `s` is confirmed to adhere to the format: `yyyy-MM-ddTHH:mm:ss`.
>>
>> An alternative is using `LocalDateTime.of(..)` and extracting the date/time values ourselves from `s` with the known positions which is considerably faster but not as concise.
>
> Justin Lu has updated the pull request incrementally with one additional commit since the last revision:
>
> generalize format comment
src/java.base/share/classes/java/util/Currency.java line 1182:
> 1180: private static boolean isPastCutoverDate(String cutOver) {
> 1181: return System.currentTimeMillis() >
> 1182: LocalDateTime.parse(cutOver.trim(), DateTimeFormatter.ISO_LOCAL_DATE_TIME)
Btw, do we really need this `trim()` call?
It looks redundant. prop.date is result part of `m.group(4)` of this regexp:
https://github.com/openjdk/jdk/blob/3f1d9b573546685215af06031656efe6f1429caf/src/java.base/share/classes/java/util/Currency.java#L255-L257
`(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})`
I don't see how it could contain whitespace characters on start or end.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23374#discussion_r1939322191
More information about the i18n-dev
mailing list