Skip to content

Commit 8330a1b

Browse files
runningcodeclaude
andauthored
ref(core): Avoid boxing in DateUtils.nanosToDate (#5523)
* 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) <noreply@anthropic.com> * changelog --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a28ff12 commit 8330a1b

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Improvements
6+
7+
- Reduce unboxing in `DateUtils.nanosToDate` ([#5523](https://github.com/getsentry/sentry-java/pull/5523))
8+
39
## 8.43.2
410

511
### Improvements

sentry/src/main/java/io/sentry/DateUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ public static double nanosToMillis(final double nanos) {
115115
* @return date rounded down to milliseconds
116116
*/
117117
public static Date nanosToDate(final long nanos) {
118-
final Double millis = nanosToMillis((double) nanos);
119-
return getDateTime(millis.longValue());
118+
final double millis = nanosToMillis((double) nanos);
119+
return getDateTime((long) millis);
120120
}
121121

122122
public static @Nullable Date toUtilDate(final @Nullable SentryDate sentryDate) {

0 commit comments

Comments
 (0)