<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: "Calibri Light", "Helvetica Light", sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
I agree with this observation that most of the parsed or stored temporal fields are the built-in chrono fields. With this optimization, we might need to review our tests to ensure we won't run into crashes if we incorrectly assumed a parsing context has only
 chrono fields.</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> core-libs-dev <core-libs-dev-retn@openjdk.org> on behalf of wenshao <shaojin.wensj@alibaba-inc.com><br>
<b>Sent:</b> Monday, November 24, 2025 11:12 PM<br>
<b>To:</b> core-libs-dev <core-libs-dev@openjdk.org><br>
<b>Subject:</b> Use EnumMap instead of HashMap for DateTimeFormatter parsing to improve performance</font>
<div> </div>
</div>
<div>
<div class="x___aliyun_email_body_block">
<div style="font-family:Tahoma,Arial,STHeitiSC-Light,SimSun">
<div style="clear:both"><span></span><span>When parsing date/time strings, DateTimeFormatter creates HashMaps to store intermediate parsed values. HashMap has more overhead for operations compared to specialized map implementations.</span>
<div style="clear:both"><br>
</div>
<div style="clear:both">Since ChronoField is an enum and all keys in these maps are ChronoField instances, we can use EnumMap instead, which provides better performance for enum keys due to its optimized internal structure.</div>
<div style="clear:both"><br>
</div>
<div style="clear:both">Parsing scenarios show improvements from 12% to 95%.</div>
<div style="clear:both"><br>
</div>
<span>To better express my ideas, I submitted a draft PR: <a href="https://github.com/openjdk/jdk/pull/28471" target="_blank">
https://github.com/openjdk/jdk/pull/28471</a> , and I hope you can give me feedback.</span><span></span></div>
<div style="clear:both"><span><br>
</span></div>
<div style="clear:both"><span>-</span></div>
<div style="clear:both"><span>Shaojin Wen</span></div>
<div style="clear:both"><span><br>
</span></div>
<div style="clear:both"><span><br>
</span></div>
</div>
</div>
</div>
</body>
</html>