Skip to content

Commit

Permalink
Code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Feb 21, 2024
1 parent 8fc0091 commit 19abd86
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/OpenTelemetry/Internal/InterlockedHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ public static void Add(ref double location, double value)
// we'll end up in an Interlocked.CompareExchange loop anyway.
double currentValue = Volatile.Read(ref location);

double updatedValue;
unchecked
{
updatedValue = currentValue + value;
}

var returnedValue = Interlocked.CompareExchange(ref location, updatedValue, currentValue);
var returnedValue = Interlocked.CompareExchange(ref location, currentValue + value, currentValue);
if (returnedValue != currentValue)
{
AddRare(ref location, value, returnedValue);
Expand All @@ -40,13 +34,7 @@ private static void AddRare(ref double location, double value, double currentVal
{
sw.SpinOnce();

double updatedValue;
unchecked
{
updatedValue = currentValue + value;
}

var returnedValue = Interlocked.CompareExchange(ref location, updatedValue, currentValue);
var returnedValue = Interlocked.CompareExchange(ref location, currentValue + value, currentValue);
if (returnedValue == currentValue)
{
break;
Expand Down

0 comments on commit 19abd86

Please sign in to comment.