You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Mono.Android] JNIEnv.GetObjectArray() can use Array.Empty<T>() (#6769)
Context: https://github.com/microsoft/dotnet-podcasts
Context: #6766
While working on #6766 and reviewing `dotnet trace` output, I found
time was being spent in `JNIEnv.GetObjectArray()`:
17.09ms Mono.Android!Java.Interop.TypeManager.n_Activate(intptr,intptr,intptr,intptr,intptr,intptr)
…
4.96ms Mono.Android!Android.Runtime.JNIEnv.GetObjectArray
In this case, it is taking an array of parameters and calling a
constructor. A lot of the time we are calling empty constructors!
Reviewing `JNIEnv.GetObjectArray()` we could add a check if the array
is of length 0 and return `Array.Empty<object>()`. I also found one
other place doing `new Type[0]` we can fix while we're at it.
After the change, I instead get:
2.56ms Mono.Android!Android.Runtime.JNIEnv.GetObjectArray
I'm not able to see a noticeable difference in `dotnet new maui`,
likely as this is such as small improvement.
0 commit comments