Skip to content

Commit

Permalink
Ensure rented array is always returned (#104223)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon authored Jul 1, 2024
1 parent 53a8a01 commit 60d67b8
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ public Measurement(T value, params ReadOnlySpan<KeyValuePair<string, object?>> t
}

if (count == 0)
{
ArrayPool<KeyValuePair<string, object?>>.Shared.Return(array);
return Instrument.EmptyTags;
}

result = new KeyValuePair<string, object?>[count];
array.AsSpan().Slice(0, count).CopyTo(result.AsSpan());
Expand Down

0 comments on commit 60d67b8

Please sign in to comment.