From c33e7435f28766cfa0a49160a0b32d947d96296c Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Wed, 10 Jun 2026 14:48:00 +0200 Subject: [PATCH 1/2] ref(core): Avoid boxing in DateUtils.nanosToDate nanosToMillis already returns a primitive double, but the result was stored in a boxed Double and then unboxed again via longValue(). Keep the value primitive to drop the redundant allocation and unboxing on this conversion, which runs whenever a SentryDate is turned into a java.util.Date. Co-Authored-By: Claude Opus 4.8 (1M context) --- sentry/src/main/java/io/sentry/DateUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sentry/src/main/java/io/sentry/DateUtils.java b/sentry/src/main/java/io/sentry/DateUtils.java index f7c46844ed..5e55512ae7 100644 --- a/sentry/src/main/java/io/sentry/DateUtils.java +++ b/sentry/src/main/java/io/sentry/DateUtils.java @@ -115,8 +115,8 @@ public static double nanosToMillis(final double nanos) { * @return date rounded down to milliseconds */ public static Date nanosToDate(final long nanos) { - final Double millis = nanosToMillis((double) nanos); - return getDateTime(millis.longValue()); + final double millis = nanosToMillis((double) nanos); + return getDateTime((long) millis); } public static @Nullable Date toUtilDate(final @Nullable SentryDate sentryDate) { From 39f893012459ae203bcc60731064c114b52215fa Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Wed, 10 Jun 2026 14:49:31 +0200 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a813a8e7b..a37df18efd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Improve SDK init performance by replacing `java.net.URI` with custom string parsing for DSN ([#5448](https://github.com/getsentry/sentry-java/pull/5448)) - Remove unnecessary boxing to improve performance ([#5520](https://github.com/getsentry/sentry-java/pull/5520)) +- Reduce unboxing in `DateUtils.nanosToDate` ([#5523](https://github.com/getsentry/sentry-java/pull/5523)) ### Fixes