Skip to content

Commit

Permalink
perf(geometry): remove AggressiveInlining from longer functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jirikostiha committed Jun 4, 2023
1 parent ce92925 commit 2672d04
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/code/SMath/Geometry2D/Point2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public static N ManhattanDistance<N>((N X, N Y) point1, (N X, N Y) point2)
/// <remarks>
/// <a href="https://en.wikipedia.org/wiki/Chebyshev_distance">Wikipedia</a>
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static N ChebyshevDistance<N>((N X, N Y) point)
where N : INumber<N>
=> N.Max(N.Abs(point.X), N.Abs(point.Y));
Expand All @@ -69,18 +68,16 @@ public static N ChebyshevDistance<N>((N X, N Y) point)
/// <remarks>
/// <a href="https://en.wikipedia.org/wiki/Chebyshev_distance">Wikipedia</a>
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static N ChebyshevDistance<N>((N X, N Y) point1, (N X, N Y) point2)
where N : INumber<N>
=> N.Max(N.Abs(point1.X - point2.X), N.Abs(point1.Y - point2.Y));

/// <summary>
/// Minkowski distance of point and origin
/// Minkowski distance of point and origin.
/// </summary>
/// <remarks>
/// <a href="https://en.wikipedia.org/wiki/Minkowski_distance">Wikipedia</a>
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static N MinkowskiDistance<N>((N X, N Y) point, N r)
where N : IPowerFunctions<N>
=> N.Pow(N.Pow(N.Abs(point.X), r) + N.Pow(N.Abs(point.Y), r), N.One / r);
Expand All @@ -91,9 +88,9 @@ public static N MinkowskiDistance<N>((N X, N Y) point, N r)
/// <remarks>
/// <a href="https://en.wikipedia.org/wiki/Minkowski_distance">Wikipedia</a>
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static N MinkowskiDistance<N>((N X, N Y) point1, (N X, N Y) point2, N r)
where N : IPowerFunctions<N>
=> N.Pow(N.Pow(N.Abs(point1.X - point2.X), r) + N.Pow(N.Abs(point1.Y - point2.Y), r), N.One / r);

}
}

0 comments on commit 2672d04

Please sign in to comment.