Skip to content

Commit c40c107

Browse files
committed
perf: avoid heap allocation on .NET Core and .NET
1 parent f391fb6 commit c40c107

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Sentry/Internal/UnsampledTransaction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal sealed class UnsampledTransaction : NoOpTransaction
1212
// Although it's a little bit wasteful to create separate individual class instances here when all we're going to
1313
// report to sentry is the span count (in the client report), SDK users may refer to things like
1414
// `ITransaction.Spans.Count`, so we create an actual collection
15-
#if NETSTANDARD2_1_OR_GREATER
15+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
1616
private readonly ConcurrentBag<ISpan> _spans = [];
1717
#else
1818
private ConcurrentBag<ISpan> _spans = [];
@@ -114,7 +114,7 @@ public ISpan StartChild(string operation, SpanId spanId)
114114

115115
private void ReleaseSpans()
116116
{
117-
#if NETSTANDARD2_1_OR_GREATER
117+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
118118
_spans.Clear();
119119
#else
120120
_spans = [];

src/Sentry/TransactionTracer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public IReadOnlyList<string> Fingerprint
168168
/// <inheritdoc />
169169
public IReadOnlyDictionary<string, string> Tags => _tags;
170170

171-
#if NETSTANDARD2_1_OR_GREATER
171+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
172172
private readonly ConcurrentBag<ISpan> _spans = new();
173173
#else
174174
private ConcurrentBag<ISpan> _spans = new();
@@ -431,7 +431,7 @@ public string? Origin
431431

432432
private void ReleaseSpans()
433433
{
434-
#if NETSTANDARD2_1_OR_GREATER
434+
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
435435
_spans.Clear();
436436
#else
437437
_spans = new ConcurrentBag<ISpan>();

0 commit comments

Comments
 (0)