Skip to content

Commit

Permalink
Avoid copy on IntX.Abs
Browse files Browse the repository at this point in the history
  • Loading branch information
leppie committed Sep 19, 2019
1 parent 1a871f3 commit 06c23f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions IronScheme/Oyster.IntX/IntX.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1706,9 +1706,13 @@ internal void TryNormalize()

public IntX Abs()
{
uint[] newdigits = new uint[_digits.Length];
Array.Copy(_digits, newdigits, newdigits.Length);
return new IntX(newdigits, false);
if (_negative)
{
uint[] newdigits = new uint[_digits.Length];
Array.Copy(_digits, newdigits, newdigits.Length);
return new IntX(newdigits, false);
}
return this;
}

public double ToFloat64()
Expand Down

0 comments on commit 06c23f4

Please sign in to comment.