Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Mark MemoryMarshal.Cast methods for aggressive inlining (#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 jkotas committed Feb 28, 2018
1 parent 29d5dc2 commit 355995e
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 355995e

Please sign in to comment.