Skip to content

Commit 492cbe5

Browse files
YohDeadfallMrJul
andauthored
Avoid Select when no boxing required (#16886)
Co-authored-by: Julien Lebosquain <[email protected]>
1 parent b17153f commit 492cbe5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Avalonia.Base/AvaloniaObjectExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ public static class AvaloniaObjectExtensions
1818
/// <returns>An <see cref="IBinding"/>.</returns>
1919
public static IBinding ToBinding<T>(this IObservable<T> source)
2020
{
21-
return new BindingAdaptor(source.Select(x => (object?)x));
21+
return new BindingAdaptor(
22+
typeof(T).IsValueType
23+
? source.Select(x => (object?)x)
24+
: (IObservable<object?>)source);
2225
}
2326

2427
/// <summary>

0 commit comments

Comments
 (0)