RFR: 8370013: Refactor Double.toHexString to eliminate regex and StringBuilder [v12]

Shaojin Wen swen at openjdk.org
Tue Oct 21 05:14:48 UTC 2025


> This PR refactors the Double.toHexString method to improve its performance by eliminating the use of StringBuilder and regex operations. The new implementation uses a direct byte array approach to construct the hex string representation, which avoids the overhead of StringBuilder operations and regex pattern matching.
> 
> Existing tests in `java/lang/Double/ToHexString.java`.

Shaojin Wen has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 17 commits:

 - codestyle
 - Merge remote-tracking branch 'upstream/master' into float_to_hex_str_2510
   
   # Conflicts:
   #	test/jdk/java/lang/Double/ToHexString.java
 - copyright
 - fix test, from @jddarcy
 - extract doubleToLongBits, from @jddarcy
 - fix test comment
 - add tests for removed trailing zeros, from @jddarcy
 - from @rgiulietti
 - from @rgiulietti
 - code style, from @rgiulietti
 - ... and 7 more: https://git.openjdk.org/jdk/compare/eee29088...822c0259

-------------

Changes: https://git.openjdk.org/jdk/pull/27811/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27811&range=11
  Stats: 291 lines in 4 files changed: 157 ins; 101 del; 33 mod
  Patch: https://git.openjdk.org/jdk/pull/27811.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27811/head:pull/27811

PR: https://git.openjdk.org/jdk/pull/27811


More information about the core-libs-dev mailing list