Skip to content

Commit

Permalink
Mark MemoryMarshal.Cast methods for aggressive inlining (dotnet#16654)
Browse files Browse the repository at this point in the history
Inlining doesn't streamline the cast logic any, but it facilitates
caller struct promotion which can substantially boost perf.

See discussion in dotnet/corefx#27485.
  • Loading branch information
AndyAyersMS authored and A-And committed Feb 28, 2018
1 parent a4688c6 commit 9c412b5
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static Memory<T> AsMemory<T>(ReadOnlyMemory<T> readOnlyMemory) =>
/// <exception cref="System.ArgumentException">
/// Thrown when <typeparamref name="TFrom"/> or <typeparamref name="TTo"/> contains pointers.
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Span<TTo> Cast<TFrom, TTo>(Span<TFrom> source)
where TFrom : struct
where TTo : struct
Expand All @@ -75,6 +76,7 @@ ref Unsafe.As<TFrom, TTo>(ref source._pointer.Value),
/// <exception cref="System.ArgumentException">
/// Thrown when <typeparamref name="TFrom"/> or <typeparamref name="TTo"/> contains pointers.
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ReadOnlySpan<TTo> Cast<TFrom, TTo>(ReadOnlySpan<TFrom> source)
where TFrom : struct
where TTo : struct
Expand Down

0 comments on commit 9c412b5

Please sign in to comment.