Skip to content

Commit

Permalink
Avoid Select when no boxing required (#16886)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
  • Loading branch information
YohDeadfall and MrJul authored Oct 3, 2024
1 parent b17153f commit 492cbe5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Avalonia.Base/AvaloniaObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public static class AvaloniaObjectExtensions
/// <returns>An <see cref="IBinding"/>.</returns>
public static IBinding ToBinding<T>(this IObservable<T> source)
{
return new BindingAdaptor(source.Select(x => (object?)x));
return new BindingAdaptor(
typeof(T).IsValueType
? source.Select(x => (object?)x)
: (IObservable<object?>)source);
}

/// <summary>
Expand Down

0 comments on commit 492cbe5

Please sign in to comment.