xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.49k stars 515 forks source link

Optimization: turn calls to UIDevice.CheckSystemVersion to a constant true value #4323

Open rolfbjarne opened 6 years ago

rolfbjarne commented 6 years ago

An idea for a possible optimization in the linker:

Turn calls to UIKit.UIDevice.CurrentDevice.CheckSystemVersion (and the equivalent for macOS) to a constant true value, when a look at the deployment target proves it can never be false.

This will make such scenarios execute somewhat faster, and together with the dead code elimination optimization this should decrease app size somewhat too.

rolfbjarne commented 6 years ago

And the corollary for user apps: a code analysis rule to detect useless system version checks (taking the deployment target into account).