Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Java.Interop.Tools.TypeNameMappings] improve `ToJniNameFromAttribute…
…sForAndroid` (#1064) Reviewing `dotnet-trace` output: dotnet trace collect --format speedscope -- C:\src\xamarin-android\bin\Release\dotnet\dotnet.exe build -bl --no-restore bar.csproj On a `dotnet new maui` application, I noticed: 79.40ms java.interop.tools.javacallablewrappers!Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager.ToJniNameFromAttribute This method just appears to be called *a lot*, and so things I changed: * Check `type.HasCustomAttributes`, `attributeType.HasInterfaces`, and `attr.HasProperties` where appropriate. * Unroll the `System.Linq` usage one level, and use plain `foreach` * Create a `IsIJniNameProviderAttribute` method that checks against a list of known attribute types as a "fast path". * The "slow path" can continue to check for the `IJniNameProviderAttribute` interface Other changes: * Delete `#region`! After these changes, I get: 51.64ms (1.2%) 0.13ns (<0.01%) java.interop.tools.javacallablewrappers!Java.Interop.Tools.TypeNameMappings.JavaNativeTypeManager.ToJniNameFromAttribute This should save ~27ms on incremental builds of the `dotnet new maui` project template and likely even more on larger projects.
- Loading branch information