Commit 8ab9d33
authored
[Java.Interop.Tools.TypeNameMappings] improve
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.ToJniNameFromAttributesForAndroid (#1064)1 parent 09f8da2 commit 8ab9d33
File tree
1 file changed
+32
-10
lines changed- src/Java.Interop.Tools.TypeNameMappings/Java.Interop.Tools.TypeNameMappings
1 file changed
+32
-10
lines changedLines changed: 32 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
574 | 576 | | |
575 | 577 | | |
576 | 578 | | |
577 | 579 | | |
578 | | - | |
| 580 | + | |
579 | 581 | | |
580 | 582 | | |
581 | 583 | | |
582 | 584 | | |
583 | 585 | | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
589 | 611 | | |
590 | 612 | | |
591 | 613 | | |
| |||
0 commit comments