Skip to content

Commit 681402e

Browse files
committed
Code cleanup
1 parent 7980562 commit 681402e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/DotNext/DelegateHelpers.Utils.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ private static TDelegate ChangeType<TDelegate, TRewriter>(this Delegate d, TRewr
2525
where TRewriter : struct, ISupplier<Delegate, object?>
2626
{
2727
var list = d.GetInvocationList();
28-
if (list.LongLength == 1L)
29-
return ReferenceEquals(list[0], d) ? d.Method.CreateDelegate<TDelegate>(rewriter.Invoke(d)) : ChangeType<TDelegate, TRewriter>(list[0], rewriter);
28+
if (list is [var singleDelegate])
29+
return ReferenceEquals(singleDelegate, d)
30+
? d.Method.CreateDelegate<TDelegate>(rewriter.Invoke(d))
31+
: ChangeType<TDelegate, TRewriter>(singleDelegate, rewriter);
3032

31-
// We use untyped CreateDelegate to avoid typecast inside of the loop.
33+
// We use untyped CreateDelegate to avoid typecast inside the loop.
3234
// Also, it's reasonable to reuse already allocated invocation list to store
3335
// newly created delegates because Delegate.Combine accepts array only
3436
var delegateType = typeof(TDelegate);

0 commit comments

Comments
 (0)