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
[XABT] Use SortedSets in JCWGenerator.EnsureIdenticalCollections for better performance. (#9208)
`JCWGenerator.EnsureIdenticalCollections` ensures that every
architecture being built contains the same Java derived types. Because
this includes `Mono.Android.dll`, even the `dotnet new android`
template has ~8500 Java types found. The current implementation uses
nested loops and is O(N²). By first sorting the items into `SortedSet`
types and then using `SetEquals` we can significantly speed up this
operation.
Fresh `dotnet build` of Android template (defaults to 4
architectures), `EnsureIdenticalCollections` takes:
| | |
| - | - |
| `main` | 3081 ms |
| PR | 29 ms |
logger.LogDebugMessage($"Ensuring Java type collection in architecture '{state.TargetArch}' matches the one in architecture '{templateState.TargetArch}'");
thrownewInvalidOperationException($"Internal error: architecture '{state.TargetArch}' has a different number of types ({types.Count}) than the template architecture '{templateState.TargetArch}' ({templateTypes.Count})");
251
+
if(typesSet.Count!=templateSet.Count){
252
+
thrownewInvalidOperationException($"Internal error: architecture '{state.TargetArch}' has a different number of types ({typesSet.Count}) than the template architecture '{templateState.TargetArch}' ({templateSet.Count})");
logger.LogError($"Architecture '{state.TargetArch}' has Java types which have no counterparts in template architecture '{templateState.TargetArch}':");
270
257
271
-
if(matchedType==null){
272
-
mismatchedTypes.Add(type);
273
-
}
274
-
}
258
+
typesSet.ExceptWith(templateSet);
275
259
276
-
if(mismatchedTypes.Count>0){
277
-
logger.LogError($"Architecture '{state.TargetArch}' has Java types which have no counterparts in template architecture '{templateState.TargetArch}':");
0 commit comments