> In the Throwable::printStackTrace method, StringBuilder is created multiple > times to build String. By sharing StringBuilder to build String, object > allocation and copying are reduced. > > In the scenario without suppressed and ourCause, unused IdentityHashMap is > not created. > > Through these optimizations, the performance of `new > Exception().printStackTrace()` can be improved by about 10%.
Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision: Update src/java.base/share/classes/java/lang/Throwable.java Co-authored-by: Hendrik Schick <30866028+k...@users.noreply.github.com> ------------- Changes: - all: https://git.openjdk.org/jdk/pull/24864/files - new: https://git.openjdk.org/jdk/pull/24864/files/6160f403..6bbe90f6 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=24864&range=06 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24864&range=05-06 Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod Patch: https://git.openjdk.org/jdk/pull/24864.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/24864/head:pull/24864 PR: https://git.openjdk.org/jdk/pull/24864