Skip to content

Commit

Permalink
Bah, Humbug!
Browse files Browse the repository at this point in the history
I was hoping  typeof(T).IsValueType would get evaluated during JIT
compilation which would allow for dead code elimination, but alas:
https://github.com/dotnet/corefx/issues/16217
  • Loading branch information
halter73 committed Feb 25, 2019
1 parent 4de77e9 commit a42fff6
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ internal static class AsyncEnumeratorAdapters
public static IAsyncEnumerator<object> GetAsyncEnumeratorFromAsyncEnumerable<T>(IAsyncEnumerable<T> asyncEnumerable, CancellationToken cancellationToken = default(CancellationToken))
{
var enumerator = asyncEnumerable.GetAsyncEnumerator(cancellationToken);

if (typeof(T).IsValueType)
{
return new BoxedAsyncEnumerator<T>(enumerator);
}

return (IAsyncEnumerator<object>)enumerator;
return enumerator as IAsyncEnumerator<object> ?? new BoxedAsyncEnumerator<T>(enumerator);
}

public static IAsyncEnumerator<object> GetAsyncEnumeratorFromChannel<T>(ChannelReader<T> channel, CancellationToken cancellationToken = default(CancellationToken))
Expand Down

0 comments on commit a42fff6

Please sign in to comment.