Skip to content

Commit a42fff6

Browse files
committed
Bah, Humbug!
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
1 parent 4de77e9 commit a42fff6

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/SignalR/server/Core/src/Internal/AsyncEnumeratorAdapters.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ internal static class AsyncEnumeratorAdapters
1515
public static IAsyncEnumerator<object> GetAsyncEnumeratorFromAsyncEnumerable<T>(IAsyncEnumerable<T> asyncEnumerable, CancellationToken cancellationToken = default(CancellationToken))
1616
{
1717
var enumerator = asyncEnumerable.GetAsyncEnumerator(cancellationToken);
18-
19-
if (typeof(T).IsValueType)
20-
{
21-
return new BoxedAsyncEnumerator<T>(enumerator);
22-
}
23-
24-
return (IAsyncEnumerator<object>)enumerator;
18+
return enumerator as IAsyncEnumerator<object> ?? new BoxedAsyncEnumerator<T>(enumerator);
2519
}
2620

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

0 commit comments

Comments
 (0)