Skip to content

Commit 88119b9

Browse files
runningcodeclaude
andcommitted
perf(core): Skip Hint allocation in addBreadcrumb without callback (JAVA-605)
Only allocate a Hint when a beforeBreadcrumb callback is set. addBreadcrumb previously allocated a Hint (HashMap + ArrayList + lock) on every call even though the Hint is only ever passed to the callback, wasting allocations on the common no-callback path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent aab952b commit 88119b9

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

sentry/src/main/java/io/sentry/Scope.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,11 @@ public void addBreadcrumb(@NotNull Breadcrumb breadcrumb, @Nullable Hint hint) {
493493
if (breadcrumb == null || breadcrumbs instanceof DisabledQueue) {
494494
return;
495495
}
496-
if (hint == null) {
497-
hint = new Hint();
498-
}
499-
500496
SentryOptions.BeforeBreadcrumbCallback callback = options.getBeforeBreadcrumb();
501497
if (callback != null) {
498+
if (hint == null) {
499+
hint = new Hint();
500+
}
502501
breadcrumb = executeBeforeBreadcrumb(callback, breadcrumb, hint);
503502
}
504503
if (breadcrumb != null) {

0 commit comments

Comments
 (0)